﻿using System;
using System.Collections.Generic;
using DeHeng_Mes.Constant;
using S7.Net;
using System.Management;
using DeHeng_Mes.Model.PlcModel.P3;
using DeHeng_Mes.Model.PlcModel.P2;
using DeHeng_Mes.Model.PlcModel.P1;
using DeHeng_Mes.Model.PlcModel.P4;
using NPOI.SS.Formula.Functions;

namespace DeHeng_Mes.Utils
{
    public static class MappingTable
    {
        /// <summary>
        /// plc数据与实体类的映射
        /// </summary>
        /// <param name="plc"></param>
        /// <param name="plcName"></param>
        /// <returns></returns>
        public static Dictionary<object, Type> PlcMapping(Plc plc, string plcName)
        {
            // 初始化返回值
            Dictionary<object, Type> dic = new Dictionary<object, Type>();

            // 定义一个类型和地址的映射表
            var typeAddressMap = new Dictionary<string, List<(Type type, int address)>>
            {
                { "P1", new List<(Type, int)>
                    {
                        (typeof(P1Code), 5060),
                        (typeof(P1Power), 6002),
                        (typeof(P1Check), 5061),
                        //(typeof(P1Production), 6001),
                    }
                },
                { "P2", new List<(Type, int)>
                    {
                        (typeof(P2Code), 5060),
                        (typeof(P2Power), 6002),
                        (typeof(P2Check), 5061),
                        //(typeof(P2Production), 6001),
                    }
                },
                { "P3", new List<(Type, int)>
                    {
                        (typeof(P3Code), 5060),
                        (typeof(P3Check), 5061),
                        (typeof(P3Power), 6002),
                        //(typeof(P3Production), 6001),
                        //(typeof(P3Type), 5013),
                    }
                },
                { "P4", new List<(Type, int)>
                    {
                        (typeof(P4Code), 5060),
                        (typeof(P4Check), 5061),
                        (typeof(P4Power), 6002),
                        //(typeof(P4Production), 6001),
                    }
                }
            };

            // 定义读取数据并添加到字典的方法
            void AddInstance(Type type, int address)
            {
                // 引用ReadClass方法的命名空间和类
                var method = typeof(Plc).GetMethod("ReadClass", new Type[] { typeof(int), typeof(int) })?.MakeGenericMethod(type);
                var instance = method.Invoke(plc, new object[] { address, 0 });
                dic.Add(instance, type);
            }

            try
            {
                // 检查并处理对应的Name类型
                if (typeAddressMap.ContainsKey(plcName))
                {
                    foreach (var (type, address) in typeAddressMap[plcName])
                    {
                        AddInstance(type, address);
                    }
                }

                return dic;
            }
            catch (Exception ex)
            {
                Tools.ProduceLogTextError($"{plcName}获取Plc数据实例与实例类型映射失败，原因是：" + ex.Message);
            }

            return dic;
        }

        /// <summary>
        /// 获取Cpu唯一标识
        /// </summary>
        public static string DeviceIdentifier()
        {
            string cpuId = string.Empty;
            using (ManagementObjectSearcher searcher = new ManagementObjectSearcher("select ProcessorId from Win32_Processor"))
            {
                foreach (ManagementObject obj in searcher.Get())
                {
                    cpuId = obj["ProcessorId"].ToString();
                    break;
                }
            }
            return cpuId;
        }

        /// <summary>
        /// 设备与数据库账号映射表
        /// </summary>
        /// <param name="cpuIp"></param>
        /// <returns></returns>
        public static (string, string) GetSqlUser(string cpuIp)
        {
            string userName = "";
            string passWord = "";
            //BFEBFBFF000906EA
            //BFEBFBFF000906EA
            Dictionary<string, Dictionary<string, string>> dic = new Dictionary<string, Dictionary<string, string>>()
            {
                {"178BFBFF00A70F52",new Dictionary<string, string>()
                {
                    { "sa","yk19991223"}
                } },
                {"BFEBFBFF000806EB",new Dictionary<string, string>()
                {
                    { "sa","yk19991223"}
                } }
            };

            foreach (var item in dic)
            {
                if (item.Key.Equals(cpuIp))
                {
                    //解析Value
                    foreach (var item1 in item.Value)
                    {
                        userName = item1.Key;
                        passWord = item1.Value;
                    }
                }
            }
            userName = string.IsNullOrEmpty(userName) ? SystemConstant.MySqlName : userName;
            passWord = string.IsNullOrEmpty(passWord) ? SystemConstant.MySqlPassWord : passWord;
            return (userName, passWord);
        }

        /// <summary>
        /// 请求对照表
        /// </summary>
        /// <param name="url"></param>
        /// <returns></returns>
        public static string UrlAnalysis(string url)
        {
            Dictionary<string, string> dic
                = new Dictionary<string, string>()
                {
                    {"OrderInfo","ProcessRequest" },
                    {"ISVGlue","ISVGlue" },
                    {"ISVWeld","ISVWeld" },
                    {"receiveReport","receiveReport" },
                };
            foreach (var item in dic)
            {
                if (url.Contains(item.Key))
                {
                    return item.Value;
                }
            }
            return "";
        }

        /// <summary>
        /// 获取该类字段与Plc数据映射
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public static List<string> GetDicByName(string key)
        {
            var dic = new Dictionary<string, List<string>>();

            #region 状态读取映射
            dic["P1-STATUS"] = new List<string>()
            {
                SystemConstant.OP50L,
                SystemConstant.OP50L_1,
                SystemConstant.OP50R,
                SystemConstant.OP50R_1,
                SystemConstant.R1,
                SystemConstant.R2,
                SystemConstant.R3,
                SystemConstant.R4,
                SystemConstant.R5,
                SystemConstant.OP90L,
                SystemConstant.OP90R,
            };

            dic["P2-STATUS"] = new List<string>()
            {
                SystemConstant.OP100L,
                SystemConstant.OP100R,
                SystemConstant.OP120L,
                SystemConstant.OP120R,
                SystemConstant.OP130L,
                SystemConstant.OP130R,
            };

            dic["P3-STATUS"] = new List<string>()
            {
                SystemConstant.OP140L,
                SystemConstant.OP140R,

                SystemConstant.OP150L,
                SystemConstant.OP150R,

                SystemConstant.OP160L,
                SystemConstant.OP160R,

                SystemConstant.OP170L,
                SystemConstant.OP170R,

                SystemConstant.OP180L,
                SystemConstant.OP180R,

                SystemConstant.OP190L,
                SystemConstant.OP190R,

                SystemConstant.OP200L,
                SystemConstant.OP200R,
            };

            dic["P4-STATUS"] = new List<string>()
            {
                SystemConstant.OP210L,
                SystemConstant.OP220L,
                SystemConstant.OP230L,
                SystemConstant.OP250L,
                SystemConstant.OP260L,
                SystemConstant.OP270L,
                SystemConstant.OP280L,
                SystemConstant.NgStationL,
                SystemConstant.OP240L,

                SystemConstant.OP210R,
                SystemConstant.OP220R,
                SystemConstant.OP230R,
                SystemConstant.OP250R,
                SystemConstant.OP260R,
                SystemConstant.OP270R,
                SystemConstant.OP280R,
                SystemConstant.NgStationR,
                SystemConstant.OP240R,
            };
            #endregion

            // 返回匹配数据
            if (dic.TryGetValue(key, out var data))
                return data;

            return null;
        }

        /// <summary>
        /// 根据字符串数据获取相关DB数据的二元组
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public static Tuple<int, int> GetBytesOff(string key)
        {
            var dic = new Dictionary<string, Tuple<int, int>>();
            #region 状态读取数组
            dic["P1-STATUS"] = new Tuple<int, int>(SystemConstant.PLC01_STATUS_DB, SystemConstant.PLC01_STATUS_ENDOFF);
            dic["P2-STATUS"] = new Tuple<int, int>(SystemConstant.PLC02_STATUS_DB, SystemConstant.PLC02_STATUS_ENDOFF);
            dic["P3-STATUS"] = new Tuple<int, int>(SystemConstant.PLC03_STATUS_DB, SystemConstant.PLC03_STATUS_ENDOFF);
            dic["P4-STATUS"] = new Tuple<int, int>(SystemConstant.PLC04_STATUS_DB, SystemConstant.PLC04_STATUS_ENDOFF);
            #endregion

            #region PLC01数据数组
            dic["P1-CCD"] = new Tuple<int, int>(SystemConstant.PLC01_CCD_DB, SystemConstant.PLC01_CCD_ENDOFF);
            #endregion

            #region PLC02数据数组
            dic["P2-WELD"] = new Tuple<int, int>(SystemConstant.PLC02_WELD_DB, SystemConstant.PLC02_WELD_ENDOFF);
            dic["P2-CNC-DATA"] = new Tuple<int, int>(SystemConstant.PLC02_CNC_DATA_DB, SystemConstant.PLC02_CNC_DATA_ENDOFF);
            #endregion

            #region PLC03数据数组
            dic["P3-WELD"] = new Tuple<int, int>(SystemConstant.PLC03_WELD_DB, SystemConstant.PLC03_WELD_ENDOFF);
            #endregion

            #region PLC04数据数组
            dic["P4-GLUE"] = new Tuple<int, int>(SystemConstant.PLC04_GLUE_DB, SystemConstant.PLC04_GLUE_ENDOFF);
            dic["P4-CCD"] = new Tuple<int, int>(SystemConstant.PLC04_CCD_DB, SystemConstant.PLC04_CCD_ENDOFF);
            dic["P4-POINT"] = new Tuple<int, int>(SystemConstant.PLC04_POINT_DB, SystemConstant.PLC04_POINT_ENDOFF);
            #endregion

            if (dic.TryGetValue(key, out Tuple<int, int> value))
                return value;
            return null;
        }

        /// <summary>
        /// 根据工位获取字段数据
        /// </summary>
        /// <param name="station"></param>
        /// <returns></returns>
        public static Dictionary<string, int> GetWeldOff(string station)
        {
            Dictionary<string, Dictionary<string, int>> dic = new Dictionary<string, Dictionary<string, int>>();

            dic[SystemConstant.OP100L] = new Dictionary<string, int>()
            {
                { "Off",5},
                { "SeamNo",130},
                { "StartTime",132},
                { "EndTime",140},
                { "WeldI",148},
                { "WeldU",548},
                { "WireSpeed",948},
                { "GasFlow",1348},
                { "Job",0},
            };

            dic[SystemConstant.OP100R] = new Dictionary<string, int>()
            {
                { "Off",5},
                { "SeamNo",11586},
                { "StartTime",11588},
                { "EndTime",11596},
                { "WeldI",11604},
                { "WeldU",12004},
                { "WireSpeed",12404},
                { "GasFlow",12804},
                { "Job",160},
            };

            dic[SystemConstant.OP120L] = new Dictionary<string, int>()
            {
                { "Off",5},
                { "SeamNo",23042},
                { "StartTime",23044},
                { "EndTime",23052},
                { "WeldI",23060},
                { "WeldU",23460},
                { "WireSpeed",23860},
                { "GasFlow",24260},
                { "Job",400},
            };

            dic[SystemConstant.OP120R] = new Dictionary<string, int>()
            {
                { "Off",5},
                { "SeamNo",34498},
                { "StartTime",34500},
                { "EndTime",34508},
                { "WeldI",34516},
                { "WeldU",34916},
                { "WireSpeed",35316},
                { "GasFlow",35716},
                { "Job",560},
            };

            dic[SystemConstant.OP140L] = new Dictionary<string, int>()
            {
                { "Off",8},
                { "SeamNo",130},
                { "StartTime",132},
                { "EndTime",140},
                { "WeldI",148},
                { "WeldU",548},
                { "WireSpeed",948},
                { "GasFlow",1348},
                {"Job",0},
            };

            dic[SystemConstant.OP140R] = new Dictionary<string, int>()
            {
                { "Off",8},
                { "SeamNo",32880},
                { "StartTime",32882},
                { "EndTime",32890},
                { "WeldI",32898},
                { "WeldU",33298},
                { "WireSpeed",33698},
                { "GasFlow",34098},
                {"Job",200},
            };

            dic[SystemConstant.OP150L] = new Dictionary<string, int>()
            {
                { "Off",6},
                { "SeamNo",13204},
                { "StartTime",13206},
                { "EndTime",13214},
                { "WeldI",13222},
                { "WeldU",13622},
                { "WireSpeed",14022},
                { "GasFlow",14422},
                 {"Job",400},
            };

            dic[SystemConstant.OP150R] = new Dictionary<string, int>()
            {
                { "Off",6},
                { "SeamNo",45954},
                { "StartTime",45956},
                { "EndTime",45964},
                { "WeldI",45972},
                { "WeldU",46372},
                { "WireSpeed",46772},
                { "GasFlow",47172},
                {"Job",600},
            };

            dic[SystemConstant.OP160L] = new Dictionary<string, int>()
            {
                { "Off",6},
                { "SeamNo",23042},
                { "StartTime",23044},
                { "EndTime",23052},
                { "WeldI",23060},
                { "WeldU",23460},
                { "WireSpeed",23860},
                { "GasFlow",24260},
                {"Job",800},
            };

            dic[SystemConstant.OP160R] = new Dictionary<string, int>()
            {
                { "Off",6},
                { "SeamNo",55792},
                { "StartTime",55794},
                { "EndTime",55802},
                { "WeldI",55810},
                { "WeldU",56210},
                { "WireSpeed",56610},
                { "GasFlow",57010},
                {"Job",1000},
            };

            if (dic.TryGetValue(station, out Dictionary<string, int> value))
                return value;
            return null;
        }

        /// <summary>
        /// 铣削数据映射表
        /// </summary>
        /// <param name="station"></param>
        /// <returns></returns>
        public static Dictionary<string, int> GetCNCOff(string station)
        {
            Dictionary<string, Dictionary<string, int>> dic = new Dictionary<string, Dictionary<string, int>>();

            dic[SystemConstant.OP130L] = new Dictionary<string, int>()
            {
                { "CNCStatu",0},
                { "FeedRate",4},
                { "ActualValueZ",8},
                { "MainShaftSpeed",12},
                { "FirstKnifeCount",16},
                { "FirstKnifeLife",20},
                { "FirstKnifeWarning",24},
                { "SecondKnifeCount",28},
                { "SecondKnifeLife",32},
                { "SecondKnifeWarning",36},
                { "SetPositionZ2",40},
                { "DepthOfCut",44},
            };

            dic[SystemConstant.OP130R] = new Dictionary<string, int>()
            {
                { "CNCStatu",48},
                { "FeedRate",52},
                { "ActualValueZ",56},
                { "MainShaftSpeed",60},
                { "FirstKnifeCount",64},
                { "FirstKnifeLife",68},
                { "FirstKnifeWarning",72},
                { "SecondKnifeCount",76},
                { "SecondKnifeLife",80},
                { "SecondKnifeWarning",84},
                { "SetPositionZ2",88},
                { "DepthOfCut",92},
            };

            if (dic.TryGetValue(station, out Dictionary<string, int> value))
                return value;
            return null;
        }

        /// <summary>
        /// 获取CCD数据偏移量
        /// </summary>
        /// <param name="station"></param>
        /// <returns></returns>
        public static Dictionary<string, int> GetCCDOff(string station)
        {
            Dictionary<string, Dictionary<string, int>> dic = new Dictionary<string, Dictionary<string, int>>();

            dic[SystemConstant.OP90L] = new Dictionary<string, int>()
            {
                {"Off", 40},
                {"Number", 130},
                {"Result", 162},
            };

            dic[SystemConstant.OP90R] = new Dictionary<string, int>()
            {
                {"Off", 40},
                {"Number", 1620},
                {"Result", 1652},
            };

            dic[SystemConstant.OP280L] = new Dictionary<string, int>()
            {
                {"Off", 60},
                {"Number", 130},
                {"Result", 162},
            };

            dic[SystemConstant.OP280R] = new Dictionary<string, int>()
            {
                {"Off", 59},
                {"Number", 2300},
                {"Result", 2332},
            };

            if (dic.TryGetValue(station, out Dictionary<string, int> value))
                return value;
            return null;
        }

        /// <summary>
        /// 获取涂胶数据偏移量
        /// </summary>
        /// <param name="station"></param>
        /// <returns></returns>
        public static Dictionary<string, int> GetGlueOff(string station)
        {
            Dictionary<string, Dictionary<string, int>> dic = new Dictionary<string, Dictionary<string, int>>();

            dic[SystemConstant.OP230L] = new Dictionary<string, int>()
            {
                {"Off", 6},
                {"RangeNo", 130},
                {"StartTime", 132},
                {"EndTime", 140},
                {"Press", 148},
                {"Speed", 152},
                {"Amount", 156},
                {"Temperature", 160},
            };

            dic[SystemConstant.OP230R] = new Dictionary<string, int>()
            {
                {"Off", 6},
                {"RangeNo", 464},
                {"StartTime", 466},
                {"EndTime", 474},
                {"Press", 482},
                {"Speed", 486},
                {"Amount", 490},
                {"Temperature", 494},
            };

            if (dic.TryGetValue(station, out Dictionary<string, int> value))
            {
                return value;
            }
            return null;
        }

        /// <summary>
        /// 判断是否是否为该程序管辖的线体
        /// </summary>
        /// <param name="material_id"></param>
        /// <returns></returns>
        public static bool IsExistLine(string material_id)
        {
            return true;
        }

        /// <summary>
        /// 根据物料编码获取PlcName
        /// </summary>
        /// <param name="material_id"></param>
        /// <returns></returns>
        public static string GetPlcNameByMaterial(string material_id)
        {
            Dictionary<string, string> dic = new Dictionary<string, string>()
            {
                {"110701000285","P1,P2"},
                {"110701000288","P1,P2"},
                {"110701000289","P3"},
                {"110701000283","P3"},
                {"100101000088","P3,P4"},
                {"100101000087","P3,P4"},
            };

            if (dic.TryGetValue(material_id, out string plcName))
            {
                return plcName;
            }

            return "";
        }

        /// <summary>
        /// 根据工位获取对应工序号
        /// </summary>
        /// <param name="station"></param>
        /// <returns></returns>
        public static string GetOperationId(string station)
        {
            Dictionary<string, string> dic = new Dictionary<string, string>()
            {
                { SystemConstant.S02_OP10R,"A075"},
                { SystemConstant.S02_OP20R,"A076"},
                { SystemConstant.S01_OP10R,"A217"},
                { SystemConstant.S01_OP20R,"A218"},
                { SystemConstant.S03_OP10R,"A219"},
                { SystemConstant.S03_OP20R,"A077"},

                { SystemConstant.OP10R1,"A146"},
                { SystemConstant.OP10R2,"A146"},
                { SystemConstant.OP20R1,"A228"},
                { SystemConstant.OP20R2,"A228"},
                { SystemConstant.OP30R,"A078"},
                { SystemConstant.OP40R,"A220"},
                { SystemConstant.R2,"A272"},
                { SystemConstant.R3,"A273"},
                { SystemConstant.R4,"A274"},
                { SystemConstant.R5,"A284"},
                { SystemConstant.OP90R,"A059"},
                { SystemConstant.OP100R,"A151"},
                { SystemConstant.OP120R,"A236"},
                { SystemConstant.OP130R,"A211"},
                { SystemConstant.OP140R,"A237"},
                { SystemConstant.OP150R,"A251"},
                { SystemConstant.OP160R,"A288"},
                { SystemConstant.OP170R,"A147"},
                { SystemConstant.OP180R,"A163"},
                { SystemConstant.OP190R,"A164"},
                { SystemConstant.OP200R,"A240"},
                { SystemConstant.OP210R,"A080"},
                { SystemConstant.OP220R,"A241"},
                { SystemConstant.OP230R,"A167"},
                { SystemConstant.OP240R,"A188"},
                { SystemConstant.OP250R,"A264"},
                { SystemConstant.OP260R,"A265"},
                { SystemConstant.OP270R,"A002"},
                { SystemConstant.OP280R,"A281"},


                { SystemConstant.S02_OP10L,"A075"},
                { SystemConstant.S02_OP20L,"A076"},
                { SystemConstant.S01_OP10L,"A217"},
                { SystemConstant.S01_OP20L,"A218"},
                { SystemConstant.S03_OP10L,"A219"},
                { SystemConstant.S03_OP20L,"A077"},

                { SystemConstant.OP10L1,"A146"},
                { SystemConstant.OP10L2,"A146"},
                { SystemConstant.OP20L1,"A228"},
                { SystemConstant.OP20L2,"A228"},
                { SystemConstant.OP30L,"A078"},
                { SystemConstant.OP40L,"A220"},
                { SystemConstant.OP45L,"A221"},
                { SystemConstant.R1,"A272"},
                { SystemConstant.OP90L,"A059"},
                { SystemConstant.OP100L,"A151"},
                { SystemConstant.OP120L,"A236"},
                { SystemConstant.OP130L,"A211"},
                { SystemConstant.OP140L,"A237"},
                { SystemConstant.OP150L,"A251"},
                { SystemConstant.OP160L,"A288"},
                { SystemConstant.OP170L,"A147"},
                { SystemConstant.OP180L,"A163"},
                { SystemConstant.OP190L,"A164"},
                { SystemConstant.OP200L,"A240"},
                { SystemConstant.OP210L,"A080"},
                { SystemConstant.OP220L,"A241"},
                { SystemConstant.OP230L,"A167"},
                { SystemConstant.OP240L,"A188"},
                { SystemConstant.OP250L,"A264"},
                { SystemConstant.OP260L,"A265"},
                { SystemConstant.OP270L,"A002"},
                { SystemConstant.OP280L,"A281"},
            };

            if (dic.TryGetValue(station, out string value))
            {
                return value;
            }

            return "未映射";
        }

        /// <summary>
        /// 获取FDS工艺数据名称
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public static List<string> GetFDSDataName(string key)
        {
            Dictionary<string, List<string>> keyValuePairs = new Dictionary<string, List<string>>();

            keyValuePairs["1"] = new List<string>()
            {
                "速度",
                "压力",
                "深度",
            };

            keyValuePairs["3"] = new List<string>()
            {
                "速度",
                "压力",
                "深度",
            };

            keyValuePairs["8"] = new List<string>()
            {
                "转速",
                "扭矩",
            };

            if (keyValuePairs.TryGetValue(key, out var value))
            {
                return value;
            }

            return null;
        }

        /// <summary>
        /// 判断是否是首工位
        /// </summary>
        /// <param name="station"></param>
        public static bool GetStartStation(string station)
        {
            List<string> strings = new List<string>()
            {
                SystemConstant.S02_OP10R,
                SystemConstant.S01_OP10R,
                SystemConstant.S03_OP10R,
                SystemConstant.OP10R1,
                SystemConstant.OP10R2,
                SystemConstant.OP140R,
                SystemConstant.OP180R,

                SystemConstant.S02_OP10L,
                SystemConstant.S01_OP10L,
                SystemConstant.S03_OP10L,
                SystemConstant.OP10L1,
                SystemConstant.OP10L2,
                SystemConstant.OP140L,
                SystemConstant.OP180L,
            };

            if (strings.Contains(station))
            {
                return true;
            }

            return false;
        }

        /// <summary>
        /// 判断是否是最后一个工位
        /// </summary>
        /// <param name="station"></param>
        /// <returns></returns>
        public static bool GetEndStation(string station)
        {
            List<string> strings = new List<string>()
            {
                SystemConstant.S02_OP20R,
                SystemConstant.S01_OP20R,
                SystemConstant.S03_OP20R,
                SystemConstant.OP130R,
                SystemConstant.OP170R,
                SystemConstant.OP280R,

                SystemConstant.S02_OP20L,
                SystemConstant.S01_OP20L,
                SystemConstant.S03_OP20L,
                SystemConstant.OP130L,
                SystemConstant.OP170L,
                SystemConstant.OP280L,
            };

            if (strings.Contains(station))
                return true;
            return false;
        }

        /// <summary>
        /// 根据工位号获取物料编码
        /// </summary>
        /// <param name="station"></param>
        /// <returns></returns>
        public static string GetMaterialByStation(string station)
        {
            Dictionary<string, string> dic = new Dictionary<string, string>()
            {
                { SystemConstant.S02_OP10R,"110701000333"},
                { SystemConstant.S02_OP20R,"110701000333"},

                { SystemConstant.S01_OP10R,"110701000334"},
                { SystemConstant.S01_OP20R,"110701000334"},

                { SystemConstant.S03_OP10R,"110701000428"},
                { SystemConstant.S03_OP20R,"110701000428"},

                { SystemConstant.OP10R1,"110701000288"},
                { SystemConstant.OP10R2,"110701000288"},
                { SystemConstant.OP20R1,"110701000288"},
                { SystemConstant.OP20R2,"110701000288"},
                { SystemConstant.OP30R,"110701000288"},
                { SystemConstant.OP40R,"110701000288"},
                { SystemConstant.R1,"110701000288"},
                { SystemConstant.R3R,"110701000288"},
                { SystemConstant.R4R,"110701000288"},
                { SystemConstant.R5R,"110701000288"},
                { SystemConstant.OP90R,"110701000288"},
                { SystemConstant.OP100R,"110701000288"},
                { SystemConstant.OP120R,"110701000288"},
                { SystemConstant.OP130R,"110701000288"},

                { SystemConstant.OP140R,"110701000289"},
                { SystemConstant.OP150R,"110701000289"},
                { SystemConstant.OP160R,"110701000289"},
                { SystemConstant.OP170R,"110701000289"},

                { SystemConstant.OP180R,"100101000088"},
                { SystemConstant.OP190R,"100101000088"},
                { SystemConstant.OP200R,"100101000088"},
                { SystemConstant.OP210R,"100101000088"},
                { SystemConstant.OP220R,"100101000088"},
                { SystemConstant.OP230R,"100101000088"},
                { SystemConstant.OP240R,"100101000088"},
                { SystemConstant.OP250R,"100101000088"},
                { SystemConstant.OP260R,"100101000088"},
                { SystemConstant.OP270R,"100101000088"},
                { SystemConstant.OP280R,"100101000088"},
                /**/
                { SystemConstant.S02_OP10L,"110701000330"},
                { SystemConstant.S02_OP20L,"110701000330"},

                { SystemConstant.S01_OP10L,"110701000331"},
                { SystemConstant.S01_OP20L,"110701000331"},

                { SystemConstant.S03_OP10L,"110701000335"},
                { SystemConstant.S03_OP20L,"110701000335"},

                { SystemConstant.OP10L1,"110701000285"},
                { SystemConstant.OP10L2,"110701000285"},
                { SystemConstant.OP20L1,"110701000285"},
                { SystemConstant.OP20L2,"110701000285"},
                { SystemConstant.OP30L,"110701000285"},
                { SystemConstant.OP40L,"110701000285"},
                { SystemConstant.OP45L,"110701000285"},
                { SystemConstant.R2,"110701000285"},
                { SystemConstant.R3L,"110701000285"},
                { SystemConstant.R4L,"110701000285"},
                { SystemConstant.R5L,"110701000285"},
                { SystemConstant.OP90L,"110701000285"},
                { SystemConstant.OP100L,"110701000285"},
                { SystemConstant.OP120L,"110701000285"},
                { SystemConstant.OP130L,"110701000285"},

                { SystemConstant.OP140L,"110701000283"},
                { SystemConstant.OP150L,"110701000283"},
                { SystemConstant.OP160L,"110701000283"},
                { SystemConstant.OP170L,"110701000283"},

                { SystemConstant.OP180L,"100101000087"},
                { SystemConstant.OP190L,"100101000087"},
                { SystemConstant.OP200L,"100101000087"},
                { SystemConstant.OP210L,"100101000087"},
                { SystemConstant.OP220L,"100101000087"},
                { SystemConstant.OP230L,"100101000087"},
                { SystemConstant.OP240L,"100101000087"},
                { SystemConstant.OP250L,"100101000087"},
                { SystemConstant.OP260L,"100101000087"},
                { SystemConstant.OP270L,"100101000087"},
                { SystemConstant.OP280L,"100101000087"},
            };

            if (dic.TryGetValue(station, out string value))
            {
                return value;
            }

            return "";
        }

        /// <summary>
        /// 根据工位号获取上一工位的工位号
        /// </summary>
        /// <param name="station"></param>
        /// <returns></returns>
        public static Dictionary<int, string> GetLastStation(string station)
        {
            Dictionary<string, Dictionary<int, string>> dic = new Dictionary<string, Dictionary<int, string>>()
            {
                #region 右侧
                { SystemConstant.OP50R,new Dictionary<int, string>(){ { 1, SystemConstant.OP40R} } },
                { SystemConstant.OP50R_1,new Dictionary<int, string>(){ { 1, SystemConstant.OP40R } } },
                { SystemConstant.R3,new Dictionary<int, string>(){ { 1, SystemConstant.R2 + "," + SystemConstant.R1 }, { 2, SystemConstant.R2 + "," + SystemConstant.R1 } } },
                { SystemConstant.R4,new Dictionary<int, string>(){ { 1, SystemConstant.R3 }, { 2, SystemConstant.R3 } } },
                { SystemConstant.R5,new Dictionary<int, string>(){ { 1, SystemConstant.R4 }, { 2, SystemConstant.R4 } } },
                { SystemConstant.OP90R,new Dictionary<int, string>(){ { 1, SystemConstant.R5 }, { 2, SystemConstant.R5 } } },

                { SystemConstant.OP100R,new Dictionary<int, string>(){ { 1, SystemConstant.OP90R } } },
                { SystemConstant.OP120R,new Dictionary<int, string>(){ { 1, SystemConstant.OP100R } } },
                { SystemConstant.OP130R,new Dictionary<int, string>(){ { 1, SystemConstant.OP120R } } },

                { SystemConstant.OP140R,new Dictionary<int, string>(){ { 1,  SystemConstant.S01_OP20L + "," + SystemConstant.S01_OP20R} }}, // 压铆单机
                { SystemConstant.OP150R,new Dictionary<int, string>(){ { 1, SystemConstant.OP140R },{2, SystemConstant.S02_OP20L + "," + SystemConstant.S02_OP20R } }}, // 压铆单机
                { SystemConstant.OP160R,new Dictionary<int, string>(){ { 1, SystemConstant.OP150R } }},
                { SystemConstant.OP170R,new Dictionary<int, string>(){ { 1, SystemConstant.OP160R },{ 2, SystemConstant.OP130R } }},
                { SystemConstant.OP180R,new Dictionary<int, string>(){ { 1, SystemConstant.OP170R + "," + SystemConstant.OP130R }, { 2, SystemConstant.OP170R } }},
                { SystemConstant.OP190R,new Dictionary<int, string>(){ { 1, SystemConstant.OP180R } }},
                { SystemConstant.OP200R,new Dictionary<int, string>(){ { 1, SystemConstant.OP190R } }},

                { SystemConstant.OP210R,new Dictionary<int, string>(){ { 1, SystemConstant.OP200R },{ 2, SystemConstant.S03_OP20L + "," + SystemConstant.S03_OP20R } }},
                { SystemConstant.OP220R,new Dictionary<int, string>(){ { 1, SystemConstant.OP210R } }},
                { SystemConstant.OP230R,new Dictionary<int, string>(){ { 1, SystemConstant.OP220R } }},
                { SystemConstant.OP240R,new Dictionary<int, string>(){ { 1, SystemConstant.OP230R } }},
                { SystemConstant.OP250R,new Dictionary<int, string>(){ { 1, SystemConstant.OP240R } }},
                { SystemConstant.OP260R,new Dictionary<int, string>(){ { 1, SystemConstant.OP250R } }},
                { SystemConstant.OP270R,new Dictionary<int, string>(){ { 1, SystemConstant.OP280R } }},
                { SystemConstant.OP280R,new Dictionary<int, string>(){ { 1, SystemConstant.OP260R } }},
                #endregion
                
                #region 左侧
                { SystemConstant.OP50L,new Dictionary<int, string>(){ { 1, SystemConstant.OP45L} } },
                { SystemConstant.OP50L_1,new Dictionary<int, string>(){ { 1, SystemConstant.OP45L} } },
                { SystemConstant.OP90L,new Dictionary<int, string>(){ { 1, SystemConstant.R5 }, { 2, SystemConstant.R5 } } },

                { SystemConstant.OP100L,new Dictionary<int, string>(){ { 1, SystemConstant.OP90L } } },
                { SystemConstant.OP120L,new Dictionary<int, string>(){ { 1, SystemConstant.OP100L } } },
                { SystemConstant.OP130L,new Dictionary<int, string>(){ { 1, SystemConstant.OP120L } } },

                { SystemConstant.OP140L,new Dictionary<int, string>(){ { 1, SystemConstant.S01_OP20L + "," + SystemConstant.S01_OP20R} }}, // 压铆单机
                { SystemConstant.OP150L,new Dictionary<int, string>(){ { 1, SystemConstant.OP140L },{2, SystemConstant.S02_OP20L + "," + SystemConstant.S02_OP20R } }}, // 压铆单机
                { SystemConstant.OP160L,new Dictionary<int, string>(){ { 1, SystemConstant.OP150L } }},
                { SystemConstant.OP170L,new Dictionary<int, string>(){ { 1, SystemConstant.OP160L },{ 2, SystemConstant.OP130L } }},
                { SystemConstant.OP180L,new Dictionary<int, string>(){ { 1, SystemConstant.OP170L + "," + SystemConstant.OP130L }, { 2, SystemConstant.OP170L } }},
                { SystemConstant.OP190L,new Dictionary<int, string>(){ { 1, SystemConstant.OP180L } }},
                { SystemConstant.OP200L,new Dictionary<int, string>(){ { 1, SystemConstant.OP190L } }},

                { SystemConstant.OP210L,new Dictionary<int, string>(){ { 1, SystemConstant.OP200L },{ 2, SystemConstant.S03_OP20L + "," + SystemConstant.S03_OP20R }}},
                { SystemConstant.OP220L,new Dictionary<int, string>(){ { 1, SystemConstant.OP210L } }},
                { SystemConstant.OP230L,new Dictionary<int, string>(){ { 1, SystemConstant.OP220L } }},
                { SystemConstant.OP240L,new Dictionary<int, string>(){ { 1, SystemConstant.OP230L } }},
                { SystemConstant.OP250L,new Dictionary<int, string>(){ { 1, SystemConstant.OP240L } }},
                { SystemConstant.OP260L,new Dictionary<int, string>(){ { 1, SystemConstant.OP250L } }},
                { SystemConstant.OP270L,new Dictionary<int, string>(){ { 1, SystemConstant.OP280L } }},
                { SystemConstant.OP280L,new Dictionary<int, string>(){ { 1, SystemConstant.OP260L } }},
                #endregion
            };

            if (dic.TryGetValue(station, out var value))
            {
                return value;
            }

            return null;
        }

        /// <summary>
        /// 根据PlcName与StationName获取工艺名称
        /// </summary>
        /// <param name="plcName"></param>
        /// <param name="StationName"></param>
        /// <returns></returns>
        public static string GetOperationNo(string plcName, string StationName)
        {
            var dic = new Dictionary<string, Dictionary<string, string>>();

            dic["P1"] = new Dictionary<string, string>
            {
                { SystemConstant.OP50L,"CLINCH"},
                { SystemConstant.OP50R,"CLINCH"},
                { SystemConstant.R1,"CLINCH"},
                { SystemConstant.R2,"CLINCH"},
                { SystemConstant.R3,"CLINCH"},
                { SystemConstant.R4,"CLINCH"},
                { SystemConstant.R5,"CLINCH"},
                { SystemConstant.OP90L,"CCD"},
                { SystemConstant.OP90R,"CCD"},
            };

            dic["P2"] = new Dictionary<string, string>
            {
                { SystemConstant.OP100L,"WELD"},
                { SystemConstant.OP100R,"WELD"},
                { SystemConstant.OP120L,"WELD"},
                { SystemConstant.OP120R,"WELD"},
                { SystemConstant.OP130L,"CNC"},
                { SystemConstant.OP130R,"CNC"},
            };

            dic["P3"] = new Dictionary<string, string>
            {
                { SystemConstant.OP140L,"WELD"},
                { SystemConstant.OP140R,"WELD"},
                { SystemConstant.OP150L,"WELD"},
                { SystemConstant.OP150R,"WELD"},
                { SystemConstant.OP160L,"WELD"},
                { SystemConstant.OP160R,"WELD"},
                { SystemConstant.OP170L,"WELDVISION"},
                { SystemConstant.OP170R,"WELDVISION"},
                { SystemConstant.OP180L,"TIGHTEN"},
                { SystemConstant.OP180R,"TIGHTEN"},
                { SystemConstant.OP190L,"TIGHTEN"},
                { SystemConstant.OP190R,"TIGHTEN"},
                { SystemConstant.OP200L,"TIGHTEN"},
                { SystemConstant.OP200R,"TIGHTEN"},
            };

            dic["P4"] = new Dictionary<string, string>
            {
                { SystemConstant.OP210L,"FDS"},
                { SystemConstant.OP210R,"FDS"},
                { SystemConstant.OP220L,"TIGHTEN"},
                { SystemConstant.OP220R,"TIGHTEN"},
                { SystemConstant.OP230L,"GLUE"},
                { SystemConstant.OP230R,"GLUE"},
                { SystemConstant.OP240L,"FDS"},
                { SystemConstant.OP240R,"FDS"},
                { SystemConstant.OP250L,"TIGHTEN"},
                { SystemConstant.OP250R,"TIGHTEN"},
                { SystemConstant.OP260L,"TIGHTEN"},
                { SystemConstant.OP260R,"TIGHTEN"},
                { SystemConstant.OP270L,"POINT"},
                { SystemConstant.OP270R,"POINT"},
                { SystemConstant.OP280L,"CCD"},
                { SystemConstant.OP280R,"CCD"},
            };

            if (dic.TryGetValue(plcName, out Dictionary<string, string> operationDic))
            {
                if (operationDic.TryGetValue(StationName, out string value))
                    return value;
            }
            return null;
        }

        public static (string errorType, string errorMessage) GetP1ErrorMessage(int @byte, int sty)
        {
            Dictionary<string, (string, string)> dic = new Dictionary<string, (string, string)>();

            dic[$"{0}.{0}"] = ("PLC关联故障", "P1-上游PLC关联故障");
            dic[$"{0}.{1}"] = ("PLC关联故障", "P1-下游PLC关联故障");

            dic[$"{2}.{0}"] = ("机器人故障", "P1-R1机器人故障");
            dic[$"{4}.{0}"] = ("机器人故障", "P1-R2机器人故障");
            dic[$"{6}.{0}"] = ("机器人故障", "P1-R3机器人故障");
            dic[$"{8}.{0}"] = ("机器人故障", "P1-R4机器人故障");
            dic[$"{10}.{0}"] =("机器人故障", "P1-R5机器人故障");

            dic[$"{22}.{0}"] = ("左侧夹具故障", "P1-OP50L_JIG报错");
            dic[$"{22}.{1}"] = ("左侧夹具故障", "P1-OP60L_JIG报错");
            dic[$"{22}.{2}"] = ("左侧夹具故障", "P1-OP70L_JIG报错");
            dic[$"{22}.{3}"] = ("左侧夹具故障", "P1-OP80L_JIG报错");
            dic[$"{22}.{4}"] = ("左侧夹具故障", "P1-OP80_L_NG报错");
            dic[$"{22}.{5}"] = ("左侧夹具故障", "P1-OP90L_JIG报错");

            dic[$"{24}.{0}"] = ("右侧夹具故障", "P1-OP50R_JIG报错");
            dic[$"{24}.{1}"] = ("右侧夹具故障", "P1-OP60R_JIG报错");
            dic[$"{24}.{2}"] = ("右侧夹具故障", "P1-OP70R_JIG报错");
            dic[$"{24}.{3}"] = ("右侧夹具故障", "P1-OP80R_JIG报错");
            dic[$"{24}.{4}"] = ("右侧夹具故障", "P1-OP80_R_NG报错");
            dic[$"{24}.{5}"] = ("右侧夹具故障", "P1-OP90R_JIG报错");

            dic[$"{26}.{0}"] = ("左侧夹具传感器故障", "P1-OP50L_JIG_SEN报错");
            dic[$"{26}.{1}"] = ("左侧夹具传感器故障", "P1-OP60L_JIG_SEN报错");
            dic[$"{26}.{2}"] = ("左侧夹具传感器故障", "P1-OP70L_JIG_SEN报错");
            dic[$"{26}.{3}"] = ("左侧夹具传感器故障", "P1-OP80L_JIG_SEN报错");
            dic[$"{26}.{4}"] = ("左侧夹具传感器故障", "P1-OP80L_NG_SEN报错");
            dic[$"{26}.{5}"] = ("左侧夹具传感器故障", "P1-OP90L_JIG_SEN报错");
                                                       
            dic[$"{34}.{0}"] = ("右侧夹具传感器故障", "P1-OP50R_JIG_SEN报错");
            dic[$"{34}.{1}"] = ("右侧夹具传感器故障", "P1-OP60R_JIG_SEN报错");
            dic[$"{34}.{2}"] = ("右侧夹具传感器故障", "P1-OP70R_JIG_SEN报错");
            dic[$"{34}.{3}"] = ("右侧夹具传感器故障", "P1-OP80R_JIG_SEN报错");
            dic[$"{34}.{4}"] = ("右侧夹具传感器故障", "P1-OP80R_NG_SEN报错");
            dic[$"{34}.{5}"] = ("右侧夹具传感器故障", "P1-OP90R_JIG_SEN报错");

            dic[$"{42}.{0}"] = ("电机故障", "P1-APC_L电机报错");
            dic[$"{42}.{1}"] = ("电机故障", "P1-APC_R电机报错");

            dic[$"{44}.{0}"] = ("安全门故障", "P1-SD1安全门打开");
            dic[$"{44}.{1}"] = ("安全门故障", "P1-SD2安全门打开");

            dic[$"{46}.{0}"] = ("光栅故障", "P1-PR01L_JIG报错-LC01光栅被闯入");
            dic[$"{46}.{1}"] = ("光栅故障", "P1-PR01L_JIG报错-LC02光栅被闯入");
            dic[$"{46}.{2}"] = ("光栅故障", "P1-PR01R_JIG报错-LC03光栅被闯入");
            dic[$"{46}.{3}"] = ("光栅故障", "P1-PR01R_JIG报错-LC04光栅被闯入");
            dic[$"{46}.{4}"] = ("光栅故障", "P1-OP50L_LC05光栅被闯入");
            dic[$"{46}.{5}"] = ("光栅故障", "P1-OP50L_LC06光栅被闯入");
            dic[$"{46}.{6}"] = ("光栅故障", "P1-OP50R_LC07光栅被闯入");
            dic[$"{46}.{7}"] = ("光栅故障", "P1-OP50R_LC08光栅被闯入");
            dic[$"{47}.{0}"] = ("光栅故障", "P1-PR03-PR04区域LC09隔离光栅被闯入");

            dic[$"{48}.{0}"] = ("急停", "P1-PLC1_HMI1急停");
            dic[$"{48}.{1}"] = ("急停", "P1-PLC1_HMI2急停");
            dic[$"{48}.{2}"] = ("急停", "P1-OP50L操作盒1急停");
            dic[$"{48}.{3}"] = ("急停", "P1-OP50R操作盒1急停");
            dic[$"{48}.{4}"] = ("急停", "P1-防漏检测NG盒L急停");
            dic[$"{48}.{5}"] = ("急停", "P1-防漏检测NG盒R急停");
            dic[$"{48}.{6}"] = ("急停", "P1-APC检测NG盒L急停");
            dic[$"{48}.{7}"] = ("急停", "P1-APC检测NG盒R急停");
            dic[$"{49}.{0}"] = ("急停", "P1-APC1L 按钮盒急停1");
            dic[$"{49}.{1}"] = ("急停", "P1-APC2R 按钮盒急停1");
            dic[$"{49}.{2}"] = ("急停", "P1-SD1急停");
            dic[$"{49}.{3}"] = ("急停", "P1-SD2急停");
            dic[$"{49}.{4}"] = ("急停", "P1-R1机器人急停");
            dic[$"{49}.{5}"] = ("急停", "P1-R2机器人急停");
            dic[$"{49}.{6}"] = ("急停", "P1-R3机器人急停");
            dic[$"{49}.{7}"] = ("急停", "P1-R4机器人急停");
            dic[$"{50}.{0}"] = ("急停", "P1-R5机器人急停");

            dic[$"{62}.{0}"] = ("通讯故障", "P1-CPU通讯故障");

            dic[$"{63}.{2}"] = ("通讯故障", "P1-HMI1通讯故障");
            dic[$"{63}.{3}"] = ("通讯故障", "P1-HMI2通讯故障");

            dic[$"{64}.{4}"] = ("通讯故障", "P1-MCP-ET200通讯故障");
            dic[$"{64}.{5}"] = ("通讯故障", "P1-OP50L-ET200通讯故障");
            dic[$"{64}.{6}"] = ("通讯故障", "P1-OP50R-ET200通讯故障");

            dic[$"{67}.{0}"] = ("通讯故障", "P1-OP50L_BK01通讯故障");
            dic[$"{67}.{1}"] = ("通讯故障", "P1-OP50L_BK02通讯故障");
            dic[$"{67}.{2}"] = ("通讯故障", "P1-OP50L_BK03通讯故障");
            dic[$"{67}.{3}"] = ("通讯故障", "P1-OP50L_BK04通讯故障");
            dic[$"{67}.{4}"] = ("通讯故障", "P1-OP60L_AF2_1_BK01通讯故障");
            dic[$"{67}.{5}"] = ("通讯故障", "P1-OP60R_AF2_1_BK02通讯故障");
            dic[$"{67}.{6}"] = ("通讯故障", "P1-OP60L_AF2_2_BK01通讯故障");
            dic[$"{67}.{7}"] = ("通讯故障", "P1-OP60L_AF2_2_BK02通讯故障");

            dic[$"{68}.{0}"] = ("通讯故障", "P1-OP60R_AF2_2_BK03通讯故障");
            dic[$"{68}.{1}"] = ("通讯故障", "P1-OP60R_AF2_2_BK04通讯故障");
            dic[$"{68}.{2}"] = ("通讯故障", "P1-OP60L_AF2_3_BK01通讯故障");
            dic[$"{68}.{3}"] = ("通讯故障", "P1-OP60L_AF2_3_BK02通讯故障");
            dic[$"{68}.{4}"] = ("通讯故障", "P1-OP60R_AF2_3_BK03通讯故障");
            dic[$"{68}.{5}"] = ("通讯故障", "P1-OP60R_AF2_3_BK04通讯故障");
            dic[$"{68}.{6}"] = ("通讯故障", "P1-OP80L_BK01通讯故障");
            dic[$"{68}.{7}"] = ("通讯故障", "P1-OP80R_BK02通讯故障");

            dic[$"{69}.{0}"] = ("通讯故障", "P1-OP90L_BK01通讯故障");
            dic[$"{69}.{1}"] = ("通讯故障", "P1-OP90L_BK02通讯故障");
            dic[$"{69}.{2}"] = ("通讯故障", "P1-OP90R_BK03通讯故障");
            dic[$"{69}.{3}"] = ("通讯故障", "P1-OP90R_BK04通讯故障");
                                             
            dic[$"{70}.{6}"] = ("通讯故障", "P1-OP50L_PM01通讯故障");
            dic[$"{70}.{7}"] = ("通讯故障", "P1-OP50R_PM01通讯故障");
            dic[$"{71}.{0}"] = ("通讯故障", "P1-OP60L_AF2_1_PM01通讯故障");
            dic[$"{71}.{1}"] = ("通讯故障", "P1-OP60R_AF2_1_PM01通讯故障");
            dic[$"{71}.{2}"] = ("通讯故障", "P1-OP60L_AF2_2_PM01通讯故障");
            dic[$"{71}.{3}"] = ("通讯故障", "P1-OP60R_AF2_2_PM01通讯故障");
            dic[$"{71}.{4}"] = ("通讯故障", "P1-OP60L_AF2_3_PM01通讯故障");
            dic[$"{71}.{5}"] = ("通讯故障", "P1-OP60R_AF2_3_PM01通讯故障");
            dic[$"{71}.{6}"] = ("通讯故障", "P1-OP90L_PM01通讯故障");
            dic[$"{71}.{7}"] = ("通讯故障", "P1-OP90R_PM01通讯故障");
            dic[$"{72}.{0}"] = ("通讯故障", "P1-OP90L_APC通讯故障");
            dic[$"{72}.{1}"] = ("通讯故障", "P1-OP90R_APC通讯故障");

            dic[$"{73}.{2}"] = ("通讯故障", "P1-压铆1通讯故障");
            dic[$"{74}.{0}"] = ("通讯故障", "P1-压铆2通讯故障");
            dic[$"{74}.{6}"] = ("通讯故障", "P1-压铆3通讯故障");
            dic[$"{75}.{4}"] = ("通讯故障", "P1-压铆4通讯故障");
            dic[$"{76}.{2}"] = ("通讯故障", "P1-压铆5通讯故障");

            dic[$"{77}.{0}"] = ("通讯故障", "P1-R1机器人通讯故障");
            dic[$"{77}.{1}"] = ("通讯故障", "P1-R2机器人通讯故障");
            dic[$"{77}.{2}"] = ("通讯故障", "P1-R3机器人通讯故障");
            dic[$"{77}.{3}"] = ("通讯故障", "P1-R4机器人通讯故障");
            dic[$"{77}.{4}"] = ("通讯故障", "P1-R5机器人通讯故障");

            dic[$"{83}.{2}"] = ("通讯故障", "P1-IV_L1相机通讯故障");
            dic[$"{83}.{3}"] = ("通讯故障", "P1-IV_L2相机通讯故障");
            dic[$"{83}.{4}"] = ("通讯故障", "P1-IV_L3相机通讯故障");
            dic[$"{83}.{5}"] = ("通讯故障", "P1-IV_L4相机通讯故障");
            dic[$"{83}.{6}"] = ("通讯故障", "P1-IV_R1相机通讯故障");
            dic[$"{83}.{7}"] = ("通讯故障", "P1-IV_R2相机通讯故障");
            dic[$"{84}.{0}"] = ("通讯故障", "P1-IV_R3相机通讯故障");
            dic[$"{84}.{1}"] = ("通讯故障", "P1-IV_R4相机通讯故障");

            if (dic.TryGetValue($"{@byte}.{sty}", out var value))
            {
                return value;
            }

            return ("", "");
        }

        public static (string errorType, string errorMessage) GetP2ErrorMessage(int @byte, int sty)
        {
            Dictionary<string, (string, string)> dic = new Dictionary<string, (string, string)>();

            dic[$"{0}.{0}"] = ("PLC关联故障", "P2-上游PLC关联故障");
            dic[$"{0}.{1}"] = ("PLC关联故障", "P2-下游PLC关联故障");

            dic[$"{2}.{0}"] = ("机器人故障", "P2-R6机器人故障");
            dic[$"{4}.{0}"] = ("机器人故障", "P2-R7机器人故障");
            dic[$"{6}.{0}"] = ("机器人故障", "P2-R8机器人故障");
            dic[$"{8}.{0}"] = ("机器人故障", "P2-R9机器人故障");
            dic[$"{10}.{0}"] = ("机器人故障","P2-R10机器人故障");
            dic[$"{12}.{0}"] = ("机器人故障","P2-R11机器人故障");

            dic[$"{102}.{0}"] = ("左侧夹具故障", "P2-OP100L_JIG报错");
            dic[$"{102}.{1}"] = ("左侧夹具故障", "P2-OP110L_JIG报错");
            dic[$"{102}.{2}"] = ("左侧夹具故障", "P2-OP120L_JIG报错");
            dic[$"{102}.{3}"] = ("左侧夹具故障", "P2-OP125L_JIG报错");
            dic[$"{102}.{4}"] = ("左侧夹具故障", "P2-OP130L_JIG报错");

            dic[$"{110}.{0}"] = ("右侧夹具故障", "P2-OP100R_JIG报错");
            dic[$"{110}.{1}"] = ("右侧夹具故障", "P2-OP110R_JIG报错");
            dic[$"{110}.{2}"] = ("右侧夹具故障", "P2-OP120R_JIG报错");
            dic[$"{110}.{3}"] = ("右侧夹具故障", "P2-OP125R_JIG报错");
            dic[$"{110}.{4}"] = ("右侧夹具故障", "P2-OP130R_JIG报错");

            dic[$"{118}.{0}"] = ("左侧夹具传感器故障", "P2-OP100L_JIG_SEN报错");
            dic[$"{118}.{1}"] = ("左侧夹具传感器故障", "P2-OP110L_JIG_SEN报错");
            dic[$"{118}.{2}"] = ("左侧夹具传感器故障", "P2-OP120L_JIG_SEN报错");
            dic[$"{118}.{3}"] = ("左侧夹具传感器故障", "P2-OP125L_JIG_SEN报错");
            dic[$"{118}.{4}"] = ("左侧夹具传感器故障", "P2-OP130L_JIG_SEN报错");
            dic[$"{118}.{5}"] = ("左侧夹具传感器故障", "P2-OP130L_皮带机_SEN报错");

            dic[$"{126}.{0}"] = ("右侧夹具传感器故障", "P2-OP100R_JIG_SEN报错");
            dic[$"{126}.{1}"] = ("右侧夹具传感器故障", "P2-OP110R_JIG_SEN报错");
            dic[$"{126}.{2}"] = ("右侧夹具传感器故障", "P2-OP120R_JIG_SEN报错");
            dic[$"{126}.{3}"] = ("右侧夹具传感器故障", "P2-OP125R_JIG_SEN报错");
            dic[$"{126}.{4}"] = ("右侧夹具传感器故障", "P2-OP130R_JIG_SEN报错");
            dic[$"{126}.{5}"] = ("右侧夹具传感器故障", "P2-OP130R_皮带机_SEN报错");

            dic[$"{134}.{0}"] = ("电机故障", "P2-皮带机L电机报错");
            dic[$"{134}.{1}"] = ("电机故障", "P2-皮带机R电机报错");

            dic[$"{142}.{0}"] = ("安全门故障", "P2-SD1安全门打开");
            dic[$"{142}.{1}"] = ("安全门故障", "P2-SD2安全门打开");
            dic[$"{142}.{2}"] = ("安全门故障", "P2-SD3安全门打开");

            dic[$"{144}.{0}"] = ("光栅故障", "P2-OP100L-LC01光栅被闯入");
            dic[$"{144}.{1}"] = ("光栅故障", "P2-OP100L-LC02光栅被闯入");
            dic[$"{144}.{2}"] = ("光栅故障", "P2-OP100R-LC03光栅被闯入");
            dic[$"{144}.{3}"] = ("光栅故障", "P2-OP100R-LC04光栅被闯入");
            dic[$"{144}.{4}"] = ("光栅故障", "P2-OP120L-LC05光栅被闯入");
            dic[$"{144}.{5}"] = ("光栅故障", "P2-OP120L-LC06光栅被闯入");
            dic[$"{144}.{6}"] = ("光栅故障", "P2-OP120R-LC06光栅被闯入");
            dic[$"{144}.{7}"] = ("光栅故障", "P2-OP120R-LC08光栅被闯入");
            dic[$"{145}.{0}"] = ("光栅故障", "P2-OP125L-OP40L-LC09区域隔离光栅被闯入");
            dic[$"{145}.{1}"] = ("光栅故障", "P2-OP125R-OP40R-LC10区域隔离光栅被闯入");

            dic[$"{152}.{0}"] = ("急停", "P2-HMI1急停");
            dic[$"{152}.{1}"] = ("急停", "P2-HMI2急停");
            dic[$"{152}.{2}"] = ("急停", "P2-HMI3急停");
            dic[$"{152}.{3}"] = ("急停", "P2-HMI4急停");
            dic[$"{152}.{4}"] = ("急停", "P2-OP100-OB1急停");
            dic[$"{152}.{5}"] = ("急停", "P2-OP100-OB2急停");
            dic[$"{152}.{6}"] = ("急停", "P2-OP120-OB1急停");
            dic[$"{152}.{7}"] = ("急停", "P2-OP120-OB2急停");

            dic[$"{153}.{0}"] = ("急停", "P2-SD1急停");
            dic[$"{153}.{1}"] = ("急停", "P2-SD2急停");
            dic[$"{153}.{2}"] = ("急停", "P2-SD3急停");
            dic[$"{153}.{3}"] = ("急停", "P2-R6机器人急停");
            dic[$"{153}.{4}"] = ("急停", "P2-R7机器人急停");
            dic[$"{153}.{5}"] = ("急停", "P2-R8机器人急停");
            dic[$"{153}.{6}"] = ("急停", "P2-R9机器人急停");
            dic[$"{153}.{7}"] = ("急停", "P2-R10机器人急停");

            dic[$"{154}.{0}"] = ("急停", "P2-R11机器人急停");
            dic[$"{154}.{1}"] = ("急停", "P2-OP130L皮带机OB急停");
            dic[$"{154}.{2}"] = ("急停", "P2-OP130R皮带机OB急停");

            dic[$"{166}.{0}"] = ("通讯故障", "P2-CPU通讯故障");

            dic[$"{167}.{2}"] = ("通讯故障", "P2-HMI1通讯故障");
            dic[$"{167}.{3}"] = ("通讯故障", "P2-HMI2通讯故障");
            dic[$"{167}.{4}"] = ("通讯故障", "P2-HMI3通讯故障");
            dic[$"{167}.{5}"] = ("通讯故障", "P2-HMI4通讯故障");

            dic[$"{168}.{4}"] = ("通讯故障", "P2-MCP_ET200通讯故障");
            dic[$"{168}.{5}"] = ("通讯故障", "P2-OP100L_ET200通讯故障");
            dic[$"{168}.{6}"] = ("通讯故障", "P2-OP100R_ET200通讯故障");
            dic[$"{168}.{7}"] = ("通讯故障", "P2-OP120L_ET200通讯故障");
            dic[$"{169}.{0}"] = ("通讯故障", "P2-OP120R_ET200通讯故障");

            dic[$"{171}.{0}"] = ("通讯故障", "P2-OP100L_BK01通讯故障");
            dic[$"{171}.{1}"] = ("通讯故障", "P2-OP100L_BK02通讯故障");
            dic[$"{171}.{2}"] = ("通讯故障", "P2-OP100R_BK03通讯故障");
            dic[$"{171}.{3}"] = ("通讯故障", "P2-OP100R_BK04通讯故障");
            dic[$"{171}.{4}"] = ("通讯故障", "P2-OP120L_BK01通讯故障");
            dic[$"{171}.{5}"] = ("通讯故障", "P2-OP120L_BK02通讯故障");
            dic[$"{171}.{6}"] = ("通讯故障", "P2-OP120R_BK03通讯故障");
            dic[$"{171}.{7}"] = ("通讯故障", "P2-OP120R_BK04通讯故障");
            dic[$"{172}.{0}"] = ("通讯故障", "P2-OP125L_BK01通讯故障");
            dic[$"{172}.{1}"] = ("通讯故障", "P2-OP125L_BK02通讯故障");

            dic[$"{178}.{3}"] = ("通讯故障", "P2-OP0100L_PM01通讯故障");
            dic[$"{178}.{4}"] = ("通讯故障", "P2-OP0100R_PM01通讯故障");

            dic[$"{179}.{0}"] = ("通讯故障", "P2-OP0120L_PM01通讯故障");
            dic[$"{179}.{1}"] = ("通讯故障", "P2-OP0120R_PM01通讯故障");

            dic[$"{181}.{0}"] = ("通讯故障", "P2-R6通讯故障");
            dic[$"{181}.{1}"] = ("通讯故障", "P2-R7通讯故障");
            dic[$"{181}.{2}"] = ("通讯故障", "P2-R8通讯故障");
            dic[$"{181}.{3}"] = ("通讯故障", "P2-R9通讯故障");
            dic[$"{181}.{4}"] = ("通讯故障", "P2-R10通讯故障");
            dic[$"{181}.{5}"] = ("通讯故障", "P2-R11通讯故障");

            dic[$"{183}.{4}"] = ("通讯故障", "P2-100L扫码枪通讯故障");
            dic[$"{183}.{5}"] = ("通讯故障", "P2-100R扫码枪通讯故障");
            dic[$"{183}.{6}"] = ("通讯故障", "P2-120L扫码枪通讯故障");
            dic[$"{183}.{7}"] = ("通讯故障", "P2-120R扫码枪通讯故障");
            dic[$"{184}.{0}"] = ("通讯故障", "P2-125扫码枪通讯故障");

            dic[$"{195}.{5}"] = ("通讯故障", "P2-左侧铣削台通讯故障");
            dic[$"{195}.{6}"] = ("通讯故障", "P2-右侧铣削台通讯故障");


            if (dic.TryGetValue($"{@byte}.{sty}", out var value))
            {
                return value;
            }

            return ("", "");
        }

        public static (string errorType, string errorMessage) GetP3ErrorMessage(int @byte, int sty)
        {
            Dictionary<string, (string, string)> dic = new Dictionary<string, (string, string)>();

            dic[$"{0}.{0}"] = ("PLC关联故障", "P3-上游PLC关联故障");
            dic[$"{0}.{1}"] = ("PLC关联故障", "P3-下游PLC关联故障");

            dic[$"{2}.{0}"] = ("机器人故障", "P3-R12机器人故障");
            dic[$"{4}.{0}"] = ("机器人故障", "P3-R13机器人故障");
            dic[$"{6}.{0}"] = ("机器人故障", "P3-R14机器人故障");
            dic[$"{8}.{0}"] = ("机器人故障", "P3-R15机器人故障");
            dic[$"{10}.{0}"] =("机器人故障", "P3-R16机器人故障");
            dic[$"{12}.{0}"] =("机器人故障", "P3-R17机器人故障");
            dic[$"{14}.{0}"] =("机器人故障", "P3-R18机器人故障");
            dic[$"{16}.{0}"] =("机器人故障", "P3-R19机器人故障");
            dic[$"{18}.{0}"] =("机器人故障", "P3-R20机器人故障");
            dic[$"{20}.{0}"] =("机器人故障", "P3-R21机器人故障");
            dic[$"{22}.{0}"] =("机器人故障", "P3-R22机器人故障");

            dic[$"{102}.{0}"] = ("左侧夹具故障", "P3-OP140L_JIG报错");
            dic[$"{102}.{1}"] = ("左侧夹具故障", "P3-OP150L_JIG报错");
            dic[$"{102}.{2}"] = ("左侧夹具故障", "P3-OP155L_JIG报错");
            dic[$"{102}.{3}"] = ("左侧夹具故障", "P3-OP160L_JIG报错");
            dic[$"{102}.{4}"] = ("左侧夹具故障", "P3-OP165L_JIG报错");
            dic[$"{102}.{5}"] = ("左侧夹具故障", "P3-OP170L_JIG报错");
            dic[$"{102}.{6}"] = ("左侧夹具故障", "P3-OP175L_NG_JIG报错");
            dic[$"{102}.{7}"] = ("左侧夹具故障", "P3-OP180L_JIG报错");
            dic[$"{103}.{0}"] = ("左侧夹具故障", "P3-OP190L_JIG报错");
            dic[$"{103}.{1}"] = ("左侧夹具故障", "P3-OP200L_JIG报错");
            dic[$"{103}.{2}"] = ("左侧夹具故障", "P3-AGV1L_JIG报错");
            dic[$"{103}.{3}"] = ("左侧夹具故障", "P3-AGV2L_JIG报错");
            dic[$"{103}.{4}"] = ("左侧夹具故障", "P3-AGV3L_JIG报错");

            dic[$"{110}.{0}"] = ("右侧夹具故障", "P3-OP140R_JIG报错");
            dic[$"{110}.{1}"] = ("右侧夹具故障", "P3-OP150R_JIG报错");
            dic[$"{110}.{2}"] = ("右侧夹具故障", "P3-OP155R_JIG报错");
            dic[$"{110}.{3}"] = ("右侧夹具故障", "P3-OP160R_JIG报错");
            dic[$"{110}.{4}"] = ("右侧夹具故障", "P3-OP165R_JIG报错");
            dic[$"{110}.{5}"] = ("右侧夹具故障", "P3-OP170R_JIG报错");
            dic[$"{110}.{6}"] = ("右侧夹具故障", "P3-OP175R_NG_JIG报错");
            dic[$"{110}.{7}"] = ("右侧夹具故障", "P3-OP180R_JIG报错");
            dic[$"{111}.{0}"] = ("右侧夹具故障", "P3-OP190R_JIG报错");
            dic[$"{111}.{1}"] = ("右侧夹具故障", "P3-OP200R_JIG报错");
            dic[$"{111}.{2}"] = ("右侧夹具故障", "P3-AGV1R_JIG报错");
            dic[$"{111}.{3}"] = ("右侧夹具故障", "P3-AGV2R_JIG报错");
            dic[$"{111}.{4}"] = ("右侧夹具故障", "P3-AGV3R_JIG报错");

            dic[$"{118}.{0}"] = ("左侧夹具传感器故障", "P3-OP140L_JIG_SEN报错");
            dic[$"{118}.{1}"] = ("左侧夹具传感器故障", "P3-OP150L_JIG_SEN报错");
            dic[$"{118}.{2}"] = ("左侧夹具传感器故障", "P3-OP155L_JIG_SEN报错");
            dic[$"{118}.{3}"] = ("左侧夹具传感器故障", "P3-OP160L_JIG_SEN报错");
            dic[$"{118}.{4}"] = ("左侧夹具传感器故障", "P3-OP165L_JIG_SEN报错");
            dic[$"{118}.{5}"] = ("左侧夹具传感器故障", "P3-OP170L_JIG_SEN报错");
            dic[$"{118}.{6}"] = ("左侧夹具传感器故障", "P3-OP175L_NG_JIG_SEN报错");
            dic[$"{118}.{7}"] = ("左侧夹具传感器故障", "P3-OP180L_JIG_SEN报错");
            dic[$"{119}.{0}"] = ("左侧夹具传感器故障", "P3-OP190L_JIG_SEN报错");
            dic[$"{119}.{1}"] = ("左侧夹具传感器故障", "P3-OP200L_JIG_SEN报错");

            dic[$"{126}.{0}"] = ("右侧夹具传感器故障", "P3-OP140R_JIG_SEN报错");
            dic[$"{126}.{1}"] = ("右侧夹具传感器故障", "P3-OP150R_JIG_SEN报错");
            dic[$"{126}.{2}"] = ("右侧夹具传感器故障", "P3-OP155R_JIG_SEN报错");
            dic[$"{126}.{3}"] = ("右侧夹具传感器故障", "P3-OP160R_JIG_SEN报错");
            dic[$"{126}.{4}"] = ("右侧夹具传感器故障", "P3-OP165R_JIG_SEN报错");
            dic[$"{126}.{5}"] = ("右侧夹具传感器故障", "P3-OP170R_JIG_SEN报错");
            dic[$"{126}.{6}"] = ("右侧夹具传感器故障", "P3-OP175R_NG_JIG_SEN报错");
            dic[$"{126}.{7}"] = ("右侧夹具传感器故障", "P3-OP180R_JIG_SEN报错");
            dic[$"{127}.{0}"] = ("右侧夹具传感器故障", "P3-OP190R_JIG_SEN报错");
            dic[$"{127}.{1}"] = ("右侧夹具传感器故障", "P3-OP200R_JIG_SEN报错");

            dic[$"{134}.{0}"] = ("电机故障", "P3-170皮带机L电机报错");
            dic[$"{134}.{1}"] = ("电机故障", "P3-170皮带机R电机报错");

            dic[$"{142}.{0}"] = ("安全门故障", "P3-SD1安全门打开");
            dic[$"{142}.{1}"] = ("安全门故障", "P3-SD2安全门打开");
            dic[$"{142}.{2}"] = ("安全门故障", "P3-SD3安全门打开");
            dic[$"{142}.{3}"] = ("安全门故障", "P3-SD4安全门打开");
            dic[$"{142}.{4}"] = ("安全门故障", "P3-SD5安全门打开");
            dic[$"{142}.{5}"] = ("安全门故障", "P3-SD6安全门打开");
            dic[$"{142}.{6}"] = ("安全门故障", "P3-SD7安全门打开");
            dic[$"{142}.{7}"] = ("安全门故障", "P3-SD8安全门打开");
            dic[$"{143}.{0}"] = ("安全门故障", "P3-SD9安全门打开");
            dic[$"{143}.{1}"] = ("安全门故障", "P3-SD10安全门打开");

            dic[$"{144}.{0}"] = ("光栅故障", "P3-OP140L光栅被闯入");
            dic[$"{144}.{1}"] = ("光栅故障", "P3-OP140R光栅被闯入");
            dic[$"{144}.{2}"] = ("光栅故障", "P3-OP150L光栅被闯入");
            dic[$"{144}.{3}"] = ("光栅故障", "P3-OP150R光栅被闯入");
            dic[$"{144}.{4}"] = ("光栅故障", "P3-OP160L-OP170L区域隔离光栅被闯入");
            dic[$"{144}.{5}"] = ("光栅故障", "P3-OP160R-OP170R区域隔离光栅被闯入");
            dic[$"{144}.{6}"] = ("光栅故障", "P3-OP170L光栅被闯入");
            dic[$"{144}.{7}"] = ("光栅故障", "P3-OP170R光栅被闯入");
            dic[$"{145}.{0}"] = ("光栅故障", "P3-左侧皮带下线光栅被闯入");
            dic[$"{145}.{1}"] = ("光栅故障", "P3-右侧皮带下线光栅被闯入");

            dic[$"{152}.{0}"] = ("急停", "P3-HMI1急停");
            dic[$"{152}.{1}"] = ("急停", "P3-HMI2急停");
            dic[$"{152}.{2}"] = ("急停", "P3-HMI3急停");
            dic[$"{152}.{3}"] = ("急停", "P3-HMI4急停");
            dic[$"{152}.{4}"] = ("急停", "P3-HMI5急停");
            dic[$"{152}.{5}"] = ("急停", "P3-HMI6急停");
            dic[$"{152}.{6}"] = ("急停", "P3-OP140L-OB1急停");
            dic[$"{152}.{7}"] = ("急停", "P3-OP140R-OB1急停");
            dic[$"{153}.{0}"] = ("急停", "P3-OP150L-OB1急停");
            dic[$"{153}.{1}"] = ("急停", "P3-OP150R-OB1急停");
            dic[$"{153}.{2}"] = ("急停", "P3-OP170L-OB1急停");
            dic[$"{153}.{3}"] = ("急停", "P3-OP170R-OB1急停");
            dic[$"{153}.{4}"] = ("急停", "P3-OP175L-NG1急停");
            dic[$"{153}.{5}"] = ("急停", "P3-OP175R-NG2急停");
            dic[$"{153}.{6}"] = ("急停", "P3-左侧皮带机-OB1急停");
            dic[$"{153}.{7}"] = ("急停", "P3-右侧皮带机-OB2急停");
            dic[$"{154}.{0}"] = ("急停", "P3-OP180L-OB1急停");
            dic[$"{154}.{1}"] = ("急停", "P3-OP180R-OB1急停");
            dic[$"{154}.{2}"] = ("急停", "P3-OP190L-OB1急停");
            dic[$"{154}.{3}"] = ("急停", "P3-OP190R-OB1急停");
            dic[$"{154}.{4}"] = ("急停", "P3-OP200L-OB1急停");
            dic[$"{154}.{5}"] = ("急停", "P3-OP200R-OB1急停");
            dic[$"{154}.{6}"] = ("急停", "P3-SD1安全门急停");
            dic[$"{154}.{7}"] = ("急停", "P3-SD2安全门急停");
            dic[$"{155}.{0}"] = ("急停", "P3-SD3安全门急停");
            dic[$"{155}.{1}"] = ("急停", "P3-SD4安全门急停");
            dic[$"{155}.{2}"] = ("急停", "P3-R12机器人急停");
            dic[$"{155}.{3}"] = ("急停", "P3-R13机器人急停");
            dic[$"{155}.{4}"] = ("急停", "P3-R14机器人急停");
            dic[$"{155}.{5}"] = ("急停", "P3-R15机器人急停");
            dic[$"{155}.{6}"] = ("急停", "P3-R16机器人急停");
            dic[$"{155}.{7}"] = ("急停", "P3-R17机器人急停");
            dic[$"{156}.{0}"] = ("急停", "P3-R18机器人急停");
            dic[$"{156}.{1}"] = ("急停", "P3-R19机器人急停");
            dic[$"{156}.{2}"] = ("急停", "P3-R20机器人急停");
            dic[$"{156}.{3}"] = ("急停", "P3-R21机器人急停");
            dic[$"{156}.{4}"] = ("急停", "P3-R22机器人急停");
            dic[$"{156}.{5}"] = ("急停", "P3-AGV L侧操作盒1急停");
            dic[$"{156}.{6}"] = ("急停", "P3-AGV L侧操作盒2急停");
            dic[$"{156}.{7}"] = ("急停", "P3-AGV L侧操作盒3急停");
            dic[$"{157}.{0}"] = ("急停", "P3-AGV R侧操作盒1急停");
            dic[$"{157}.{1}"] = ("急停", "P3-AGV R侧操作盒2急停");
            dic[$"{157}.{2}"] = ("急停", "P3-AGV R侧操作盒3急停");

            dic[$"{166}.{0}"] = ("通讯故障", "P3-CPU通讯故障");

            dic[$"{168}.{4}"] = ("通讯故障", "P3-MCP-ET200通讯故障");
            dic[$"{168}.{5}"] = ("通讯故障", "P3-J1-ET200通讯故障");
            dic[$"{168}.{6}"] = ("通讯故障", "P3-HMI5_ET200通讯故障");
            dic[$"{168}.{7}"] = ("通讯故障", "P3-HMI4通讯故障");
      

            dic[$"{169}.{0}"] = ("通讯故障", "P3-OP140L_ET200通讯故障");
            dic[$"{169}.{1}"] = ("通讯故障", "P3-OP140R_ET200通讯故障");
            dic[$"{169}.{2}"] = ("通讯故障", "P3-OP150L_ET200通讯故障");
            dic[$"{169}.{3}"] = ("通讯故障", "P3-OP150R_ET200通讯故障");
            dic[$"{169}.{4}"] = ("通讯故障", "P3-OP160R_ET200通讯故障");
            dic[$"{169}.{5}"] = ("通讯故障", "P3-OP160L_ET200通讯故障");
            dic[$"{169}.{6}"] = ("通讯故障", "P3-OP170L_ET200通讯故障");
            dic[$"{169}.{7}"] = ("通讯故障", "P3-OP170R_ET200通讯故障");
            dic[$"{170}.{0}"] = ("通讯故障", "P3-OP180L_ET200通讯故障");
            dic[$"{170}.{1}"] = ("通讯故障", "P3-OP190R_ET200通讯故障");
            dic[$"{170}.{2}"] = ("通讯故障", "P3-OP200L_ET200通讯故障");
            dic[$"{170}.{3}"] = ("通讯故障", "P3-OP200R_ET200通讯故障");
         
            dic[$"{171}.{0}"] = ("通讯故障", "P3-OP140L-SKS-BK01通讯故障");
            dic[$"{171}.{1}"] = ("通讯故障", "P3-OP140L-SKS-BK02通讯故障");
            dic[$"{171}.{2}"] = ("通讯故障", "P3-OP140R-SKS-BK01通讯故障");
            dic[$"{171}.{3}"] = ("通讯故障", "P3-OP140R-SKS-BK02通讯故障");
            dic[$"{171}.{4}"] = ("通讯故障", "P3-OP155L-AF-BK01通讯故障");
            dic[$"{171}.{5}"] = ("通讯故障", "P3-OP155R-AF-BK01通讯故障");
            dic[$"{171}.{6}"] = ("通讯故障", "P3-OP165L-AF-BK01通讯故障");
            dic[$"{171}.{7}"] = ("通讯故障", "P3-OP165R-AF-BK01通讯故障");
            dic[$"{172}.{0}"] = ("通讯故障", "P3-OP175L-NG-BK01通讯故障");
            dic[$"{172}.{1}"] = ("通讯故障", "P3-OP175R-NG-BK01通讯故障");
            dic[$"{172}.{2}"] = ("通讯故障", "P3-OP175R-NG-BK03通讯故障");
            dic[$"{172}.{3}"] = ("通讯故障", "P3-AVG-L1-BK1通讯故障");
            dic[$"{172}.{4}"] = ("通讯故障", "P3-AVG-L2-BK1通讯故障");
            dic[$"{172}.{5}"] = ("通讯故障", "P3-AVG-L3-BK1通讯故障");
            dic[$"{172}.{6}"] = ("通讯故障", "P3-AVG-R1-BK1通讯故障");
            dic[$"{172}.{7}"] = ("通讯故障", "P3-AVG-R2-BK1通讯故障");
            dic[$"{173}.{0}"] = ("通讯故障", "P3-AVG-R3-BK1通讯故障");

            dic[$"{177}.{3}"] = ("通讯故障", "P3-OP170L-ISVT通信故障");
            dic[$"{177}.{4}"] = ("通讯故障", "P3-OP170R-ISVT通信故障");

            dic[$"{178}.{3}"] = ("通讯故障", "P3-OP140L-AJ6-PM通讯故障");
            dic[$"{178}.{4}"] = ("通讯故障", "P3-OP140R-AJ6-PM通讯故障");
            dic[$"{178}.{5}"] = ("通讯故障", "P3-OP150L-AJ7-PM通讯故障");
            dic[$"{178}.{6}"] = ("通讯故障", "P3-OP150R-AJ7-PM通讯故障");
            dic[$"{178}.{7}"] = ("通讯故障", "P3-OP160L-AJ8-PM通讯故障");

            dic[$"{179}.{0}"] = ("通讯故障", "P3-OP160R-AJ8-PM通讯故障");
            dic[$"{179}.{1}"] = ("通讯故障", "P3-OP170L-AJ9-PM通讯故障");
            dic[$"{179}.{2}"] = ("通讯故障", "P3-OP170R-AJ9-PM通讯故障");
            dic[$"{179}.{3}"] = ("通讯故障", "P3-OP180L-AJ10-PM通讯故障");
            dic[$"{179}.{4}"] = ("通讯故障", "P3-OP180R-AJ10-PM通讯故障");
            dic[$"{179}.{5}"] = ("通讯故障", "P3-OP190L-AJ11-PM通讯故障");
            dic[$"{179}.{6}"] = ("通讯故障", "P3-OP190R-AJ11-PM通讯故障");
            dic[$"{179}.{7}"] = ("通讯故障", "P3-OP200L-AJ12-PM通讯故障");

            dic[$"{180}.{0}"] = ("通讯故障", "P3-OP200R-AJ12-PM通讯故障");

            dic[$"{181}.{0}"] = ("通讯故障", "P3-R12机器人通信故障");
            dic[$"{181}.{1}"] = ("通讯故障", "P3-R13机器人通信故障");
            dic[$"{181}.{2}"] = ("通讯故障", "P3-R14机器人通信故障");
            dic[$"{181}.{3}"] = ("通讯故障", "P3-R15机器人通信故障");
            dic[$"{181}.{4}"] = ("通讯故障", "P3-R16机器人通信故障");
            dic[$"{181}.{5}"] = ("通讯故障", "P3-R17机器人通信故障");
            dic[$"{181}.{6}"] = ("通讯故障", "P3-R18机器人通信故障");
            dic[$"{181}.{7}"] = ("通讯故障", "P3-R19机器人通信故障");
            dic[$"{182}.{0}"] = ("通讯故障", "P3-R20机器人通信故障");
            dic[$"{182}.{1}"] = ("通讯故障", "P3-R21机器人通信故障");

            dic[$"{189}.{5}"] = ("通讯故障", "P3-OP140L扫码枪通信故障");
            dic[$"{189}.{6}"] = ("通讯故障", "P3-OP140R扫码枪通信故障");
            dic[$"{189}.{7}"] = ("通讯故障", "P3-OP150L扫码枪通信故障");

            dic[$"{190}.{0}"] = ("通讯故障", "P3-OP150R扫码枪通信故障");
            dic[$"{190}.{1}"] = ("通讯故障", "P3-OP170L扫码枪通信故障");
            dic[$"{190}.{2}"] = ("通讯故障", "P3-OP170R扫码枪通信故障");
            dic[$"{190}.{3}"] = ("通讯故障", "P3-OP170NG下线扫码枪通信故障");
            dic[$"{190}.{4}"] = ("通讯故障", "P3-OP180L扫码枪通信故障");
            dic[$"{190}.{5}"] = ("通讯故障", "P3-OP180R扫码枪通信故障");
            dic[$"{190}.{6}"] = ("通讯故障", "P3-OP190L扫码枪通信故障");
            dic[$"{190}.{7}"] = ("通讯故障", "P3-OP190R扫码枪通信故障");
            dic[$"{191}.{0}"] = ("通讯故障", "P3-OP200L扫码枪通信故障");
            dic[$"{191}.{1}"] = ("通讯故障", "P3-OP200R扫码枪通信故障");
            dic[$"{191}.{2}"] = ("通讯故障", "P3-OP175L-NG扫码枪通信故障");
            dic[$"{191}.{3}"] = ("通讯故障", "P3-OP175R-NG扫码枪通信故障");

            dic[$"{194}.{6}"] = ("通讯故障", "P3-OP180L-拧紧枪通讯故障");
            dic[$"{194}.{7}"] = ("通讯故障", "P3-OP180R-拧紧枪通讯故障");

            dic[$"{195}.{0}"] = ("通讯故障", "P3-OP190L-拧紧枪通讯故障");
            dic[$"{195}.{1}"] = ("通讯故障", "P3-OP190R-拧紧枪通讯故障");
            dic[$"{195}.{2}"] = ("通讯故障", "P3-OP200L-拧紧枪通讯故障");
            dic[$"{195}.{3}"] = ("通讯故障", "P3-OP200R-拧紧枪通讯故障");


            if (dic.TryGetValue($"{@byte}.{sty}", out var value))
            {
                return value;
            }

            return ("", "");
        }

        public static (string errorType, string errorMessage) GetP4ErrorMessage(int @byte, int sty)
        {
            Dictionary<string, (string, string)> dic = new Dictionary<string, (string, string)>();


            dic[$"{48}.{0}"] = ("PLC关联故障", "P4-上游PLC关联故障");
            dic[$"{48}.{1}"] = ("PLC关联故障", "P4-下游PLC关联故障");

            dic[$"{2}.{0}"] = ("机器人状态", "P4-R23机器人故障");
            dic[$"{4}.{0}"] = ("机器人状态", "P4-R24机器人故障");
            dic[$"{6}.{0}"] = ("机器人状态", "P4-R25机器人故障");
            dic[$"{8}.{0}"] = ("机器人状态", "P4-R26机器人故障");
            dic[$"{10}.{0}"] = ("机器人状态", "P4-R27机器人故障");
            dic[$"{12}.{0}"] = ("机器人状态", "P4-R28机器人故障");
            dic[$"{14}.{0}"] = ("机器人状态", "P4-R29机器人故障");
            dic[$"{16}.{0}"] = ("机器人状态", "P4-R30机器人故障");
            dic[$"{18}.{0}"] = ("机器人状态", "P4-R30机器人故障");

            dic[$"{102}.{0}"] = ("左侧夹具故障", "P4-OP210L_JIG报错");
            dic[$"{102}.{1}"] = ("左侧夹具故障", "P4-OP220L_JIG报错");
            dic[$"{102}.{2}"] = ("左侧夹具故障", "P4-OP225L_JIG报错");
            dic[$"{102}.{3}"] = ("左侧夹具故障", "P4-OP235L_JIG报错");
            dic[$"{102}.{4}"] = ("左侧夹具故障", "P4-OP240L_JIG报错");
            dic[$"{102}.{5}"] = ("左侧夹具故障", "P4-OP250L_JIG报错");
            dic[$"{102}.{6}"] = ("左侧夹具故障", "P4-OP260L_JIG报错");
            dic[$"{102}.{7}"] = ("左侧夹具故障", "P4-OP265L_JIG报错");
            dic[$"{103}.{0}"] = ("左侧夹具故障", "P4-OP270L_JIG报错");
            dic[$"{103}.{1}"] = ("左侧夹具故障", "P4-OP280L_JIG报错");
            dic[$"{103}.{2}"] = ("左侧夹具故障", "P4-OP290L_JIG报错");
            dic[$"{103}.{3}"] = ("左侧夹具故障", "P4-OP295L_JIG报错");

            dic[$"{110}.{0}"] = ("右侧夹具故障", "P4-OP210R_JIG报错");
            dic[$"{110}.{1}"] = ("右侧夹具故障", "P4-OP220R_JIG报错");
            dic[$"{110}.{2}"] = ("右侧夹具故障", "P4-OP225R_JIG报错");
            dic[$"{110}.{3}"] = ("右侧夹具故障", "P4-OP235R_JIG报错");
            dic[$"{110}.{4}"] = ("右侧夹具故障", "P4-OP240R_JIG报错");
            dic[$"{110}.{5}"] = ("右侧夹具故障", "P4-OP250R_JIG报错");
            dic[$"{110}.{6}"] = ("右侧夹具故障", "P4-OP260R_JIG报错");
            dic[$"{110}.{7}"] = ("右侧夹具故障", "P4-OP265R_JIG报错");
            dic[$"{111}.{0}"] = ("右侧夹具故障", "P4-OP270R_JIG报错");
            dic[$"{111}.{1}"] = ("右侧夹具故障", "P4-OP280R_JIG报错");
            dic[$"{111}.{2}"] = ("右侧夹具故障", "P4-OP290R_JIG报错");
            dic[$"{111}.{3}"] = ("右侧夹具故障", "P4-OP295R_JIG报错");

            dic[$"{118}.{0}"] = ("左侧夹具传感器故障", "P4-OP210L_JIG_SEN报错");
            dic[$"{118}.{1}"] = ("左侧夹具传感器故障", "P4-OP220L_JIG_SEN报错");
            dic[$"{118}.{2}"] = ("左侧夹具传感器故障", "P4-OP225L_JIG_SEN报错");
            dic[$"{118}.{3}"] = ("左侧夹具传感器故障", "P4-OP235L_JIG_SEN报错");
            dic[$"{118}.{4}"] = ("左侧夹具传感器故障", "P4-OP240L_JIG_SEN报错");
            dic[$"{118}.{5}"] = ("左侧夹具传感器故障", "P4-OP250L_JIG_SEN报错");
            dic[$"{118}.{6}"] = ("左侧夹具传感器故障", "P4-OP260L_JIG_SEN报错");
            dic[$"{118}.{7}"] = ("左侧夹具传感器故障", "P4-OP265L_JIG_SEN报错");
            dic[$"{119}.{0}"] = ("左侧夹具传感器故障", "P4-OP270L_JIG_SEN报错");
            dic[$"{119}.{1}"] = ("左侧夹具传感器故障", "P4-OP280L_JIG_SEN报错");
            dic[$"{119}.{2}"] = ("左侧夹具传感器故障", "P4-OP290L_JIG_SEN报错");
            dic[$"{119}.{3}"] = ("左侧夹具传感器故障", "P4-OP295L_JIG_SEN报错");

            dic[$"{126}.{0}"] = ("右侧夹具传感器故障", "P4-OP210R_JIG_SEN报错");
            dic[$"{126}.{1}"] = ("右侧夹具传感器故障", "P4-OP220R_JIG_SEN报错");
            dic[$"{126}.{2}"] = ("右侧夹具传感器故障", "P4-OP225R_JIG_SEN报错");
            dic[$"{126}.{3}"] = ("右侧夹具传感器故障", "P4-OP235R_JIG_SEN报错");
            dic[$"{126}.{4}"] = ("右侧夹具传感器故障", "P4-OP240R_JIG_SEN报错");
            dic[$"{126}.{5}"] = ("右侧夹具传感器故障", "P4-OP250R_JIG_SEN报错");
            dic[$"{126}.{6}"] = ("右侧夹具传感器故障", "P4-OP260R_JIG_SEN报错");
            dic[$"{126}.{7}"] = ("右侧夹具传感器故障", "P4-OP265R_JIG_SEN报错");
            dic[$"{127}.{0}"] = ("右侧夹具传感器故障", "P4-OP270R_JIG_SEN报错");
            dic[$"{127}.{1}"] = ("右侧夹具传感器故障", "P4-OP280R_JIG_SEN报错");
            dic[$"{127}.{2}"] = ("右侧夹具传感器故障", "P4-OP290R_JIG_SEN报错");
            dic[$"{127}.{3}"] = ("右侧夹具传感器故障", "P4-OP295R_JIG_SEN报错");

            dic[$"{134}.{0}"] = ("电机故障", "P4-OP295L皮带机L电机报错");
            dic[$"{134}.{1}"] = ("电机故障", "P4-OP295L皮带机R电机报错");

            dic[$"{142}.{0}"] = ("安全门故障", "P4-PLC4_SD1安全门打开");
            dic[$"{142}.{1}"] = ("安全门故障", "P4-PLC4_SD2安全门打开");

            dic[$"{144}.{0}"] = ("光栅故障", "P4-OP210L-LC01光栅被闯入");
            dic[$"{144}.{1}"] = ("光栅故障", "P4-OP210R-LC01光栅被闯入");
            dic[$"{144}.{2}"] = ("光栅故障", "P4-OP220L-LC01光栅被闯入");
            dic[$"{144}.{3}"] = ("光栅故障", "P4-OP220R-LC01光栅被闯入");
            dic[$"{144}.{4}"] = ("光栅故障", "P4-OP240L-LC01光栅被闯入");
            dic[$"{144}.{5}"] = ("光栅故障", "P4-OP240R-LC01光栅被闯入");
            dic[$"{144}.{6}"] = ("光栅故障", "P4-OP240-OP250区域隔离光栅被闯入");
            dic[$"{144}.{7}"] = ("光栅故障", "P4-OP250L-LC01光栅被闯入");
            dic[$"{145}.{0}"] = ("光栅故障", "P4-OP250R-LC01光栅被闯入");
            dic[$"{145}.{1}"] = ("光栅故障", "P4-OP260L-LC01光栅被闯入");
            dic[$"{145}.{2}"] = ("光栅故障", "P4-OP260R-LC01光栅被闯入");
            dic[$"{145}.{3}"] = ("光栅故障", "P4-OP290L-LC01光栅被闯入");
            dic[$"{145}.{4}"] = ("光栅故障", "P4-OP290R-LC01光栅被闯入");

            dic[$"{152}.{0}"] = ("急停", "P4-PLC4_HMI1急停");
            dic[$"{152}.{1}"] = ("急停", "P4-PLC4_HMI2急停");
            dic[$"{152}.{2}"] = ("急停", "P4-PLC4_HMI3急停");
            dic[$"{152}.{3}"] = ("急停", "P4-PLC4_HMI4急停");
            dic[$"{152}.{4}"] = ("急停", "P4-PLC4_HMI5急停");
            dic[$"{152}.{5}"] = ("急停", "P4-PLC4_HMI6急停");
            dic[$"{152}.{6}"] = ("急停", "P4-PLC4_HMI7急停");
            dic[$"{152}.{7}"] = ("急停", "P4-OP210-OB1急停");
            dic[$"{153}.{0}"] = ("急停", "P4-OP210-OB2急停");
            dic[$"{153}.{1}"] = ("急停", "P4-OP220-OB1急停");
            dic[$"{153}.{2}"] = ("急停", "P4-OP220-OB2急停");
            dic[$"{153}.{3}"] = ("急停", "P4-OP240-OB1急停");
            dic[$"{153}.{4}"] = ("急停", "P4-OP240-OB2急停");
            dic[$"{153}.{5}"] = ("急停", "P4-OP230-NG-OB1急停");
            dic[$"{153}.{6}"] = ("急停", "P4-OP230-NG-OB2急停");
            dic[$"{153}.{7}"] = ("急停", "P4-OP250-OB1急停");
            dic[$"{154}.{0}"] = ("急停", "P4-OP250-OB2急停");
            dic[$"{154}.{1}"] = ("急停", "P4-OP260-OB1急停");
            dic[$"{154}.{2}"] = ("急停", "P4-OP260-OB2急停");
            dic[$"{154}.{3}"] = ("急停", "P4-OP290-OB1急停");
            dic[$"{154}.{4}"] = ("急停", "P4-OP290-OB2急停");
            dic[$"{154}.{5}"] = ("急停", "P4-皮带机-OB1急停");
            dic[$"{154}.{6}"] = ("急停", "P4-皮带机-OB2急停");
            dic[$"{154}.{7}"] = ("急停", "P4-SD1安全门急停");
            dic[$"{155}.{0}"] = ("急停", "P4-SD2安全门急停");
            dic[$"{155}.{1}"] = ("急停", "P4-R23机器人急停");
            dic[$"{155}.{2}"] = ("急停", "P4-R24机器人急停");
            dic[$"{155}.{3}"] = ("急停", "P4-R25机器人急停");
            dic[$"{155}.{4}"] = ("急停", "P4-R26机器人急停");
            dic[$"{155}.{5}"] = ("急停", "P4-R27机器人急停");
            dic[$"{155}.{6}"] = ("急停", "P4-R28机器人急停");
            dic[$"{155}.{7}"] = ("急停", "P4-R29机器人急停");
            dic[$"{156}.{0}"] = ("急停", "P4-R30机器人急停");
            dic[$"{156}.{1}"] = ("急停", "P4-R31机器人急停");
            dic[$"{156}.{2}"] = ("急停", "P4-FDS急停");

            dic[$"{166}.{0}"] = ("通讯故障", "CPU通讯故障");

            dic[$"{167}.{2}"] = ("通讯故障", "P4-HMI1通讯故障");
            dic[$"{167}.{3}"] = ("通讯故障", "P4-HMI2通讯故障");
            dic[$"{167}.{4}"] = ("通讯故障", "P4-HMI3通讯故障");
            dic[$"{167}.{5}"] = ("通讯故障", "P4-HMI4通讯故障");
            dic[$"{167}.{6}"] = ("通讯故障", "P4-HMI5通讯故障");
            dic[$"{167}.{7}"] = ("通讯故障", "P4-HMI6通讯故障");
            dic[$"{168}.{0}"] = ("通讯故障", "P4-HMI7通讯故障");

            dic[$"{168}.{4}"] = ("通讯故障", "P4-MCP-ET200SP通讯故障");
            dic[$"{168}.{5}"] = ("通讯故障", "P4-HMI1-ET200SP通讯故障");
            dic[$"{168}.{6}"] = ("通讯故障", "P4-HMI2-ET200SP通讯故障");
            dic[$"{168}.{7}"] = ("通讯故障", "P4-OP210L-AJ13-ET200SP通讯故障");

            dic[$"{169}.{0}"] = ("通讯故障", "P4-OP210R-AJ13-ET200SP通讯故障");
            dic[$"{169}.{1}"] = ("通讯故障", "P4-OP220L-AJ14-ET200SP通讯故障");
            dic[$"{169}.{2}"] = ("通讯故障", "P4-OP220R-AJ14-ET200SP通讯故障");
            dic[$"{169}.{3}"] = ("通讯故障", "P4-OP240L-AJ17-ET200SP通讯故障");
            dic[$"{169}.{4}"] = ("通讯故障", "P4-OP240R-AJ17-ET200SP通讯故障");
            dic[$"{169}.{5}"] = ("通讯故障", "P4-OP260L-AJ19-ET200SP通讯故障");
            dic[$"{169}.{6}"] = ("通讯故障", "P4-OP260R-AJ19-ET200SP通讯故障");
            dic[$"{169}.{7}"] = ("通讯故障", "P4-OP250L-AJ18-ET200SP通讯故障");

            dic[$"{170}.{0}"] = ("通讯故障", "P4-OP250R-AJ18-ET200SP通讯故障");
            dic[$"{170}.{1}"] = ("通讯故障", "P4-OP290L-AJ22-ET200SP通讯故障");
            dic[$"{170}.{2}"] = ("通讯故障", "P4-OP290R-AJ22-ET200SP通讯故障");

            dic[$"{171}.{0}"] = ("通讯故障", "P4-OP210L-AJ13-PM通讯故障");
            dic[$"{171}.{1}"] = ("通讯故障", "P4-OP210R-AJ13-PM通讯故障");
            dic[$"{171}.{2}"] = ("通讯故障", "P4-OP220L-AJ14-PM通讯故障");
            dic[$"{171}.{3}"] = ("通讯故障", "P4-OP220R-AJ14-PM通讯故障");
            dic[$"{171}.{4}"] = ("通讯故障", "P4-OP240L-AJ17-PM通讯故障");
            dic[$"{171}.{5}"] = ("通讯故障", "P4-OP240R-AJ17-PM通讯故障");
            dic[$"{171}.{6}"] = ("通讯故障", "P4-OP260L-AJ19-PM通讯故障");
            dic[$"{171}.{7}"] = ("通讯故障", "P4-OP260R-AJ19-PM通讯故障");

            dic[$"{172}.{0}"] = ("通讯故障", "P4-OP250L-AJ18-PM通讯故障");
            dic[$"{172}.{1}"] = ("通讯故障", "P4-OP250R-AJ18-PM通讯故障");
            dic[$"{172}.{6}"] = ("通讯故障", "P4-OP220L-AJ14-BK01通讯故障");
            dic[$"{172}.{7}"] = ("通讯故障", "P4-OP220L-AJ14-BK02通讯故障");
                                              
            dic[$"{173}.{0}"] = ("通讯故障", "P4-OP220R-AJ14-BK03通讯故障");
            dic[$"{173}.{1}"] = ("通讯故障", "P4-OP220R-AJ14-BK04通讯故障");
            dic[$"{173}.{2}"] = ("通讯故障", "P4-OP150L-AF15-BK01通讯故障");
            dic[$"{173}.{3}"] = ("通讯故障", "P4-OP150R-AF15-BK02通讯故障");
            dic[$"{173}.{4}"] = ("通讯故障", "P4-OP160L-AJ16-BK01通讯故障");
            dic[$"{173}.{5}"] = ("通讯故障", "P4-OP160R-AJ16-BK02通讯故障");
            dic[$"{173}.{6}"] = ("通讯故障", "P4-OP240L-AJ17-BK01通讯故障");
            dic[$"{173}.{7}"] = ("通讯故障", "P4-OP240L-AJ17-BK02通讯故障");

            dic[$"{174}.{0}"] = ("通讯故障", "P4-OP240R-AJ17-BK03通讯故障");
            dic[$"{174}.{1}"] = ("通讯故障", "P4-OP240R-AJ17-BK04通讯故障");
            dic[$"{174}.{2}"] = ("通讯故障", "P4-OP250L-AJ18-BK01通讯故障");
            dic[$"{174}.{3}"] = ("通讯故障", "P4-OP250L-AJ18-BK02通讯故障");
            dic[$"{174}.{4}"] = ("通讯故障", "P4-OP250R-AJ18-BK03通讯故障");
            dic[$"{174}.{5}"] = ("通讯故障", "P4-OP250R-AJ18-BK04通讯故障");
            dic[$"{174}.{6}"] = ("通讯故障", "P4-OP260L-AF19-BK01通讯故障");
            dic[$"{174}.{7}"] = ("通讯故障", "P4-OP260R-AF19-BK02通讯故障");

            dic[$"{175}.{0}"] = ("通讯故障", "P4-OP260L-AJ19-BK01通讯故障");
            dic[$"{175}.{1}"] = ("通讯故障", "P4-OP260L-AJ19-BK02通讯故障");
            dic[$"{175}.{2}"] = ("通讯故障", "P4-OP260R-AJ19-BK03通讯故障");
            dic[$"{175}.{3}"] = ("通讯故障", "P4-OP260R-AJ19-BK04通讯故障");
            dic[$"{175}.{4}"] = ("通讯故障", "P4-OP280L-AJ21-BK01通讯故障");
            dic[$"{175}.{5}"] = ("通讯故障", "P4-OP280R-AJ21-BK02通讯故障");
            dic[$"{175}.{6}"] = ("通讯故障", "P4-OP270L-AJ20-BK01通讯故障");
            dic[$"{175}.{7}"] = ("通讯故障", "P4-OP290L-AJ14-BK01通讯故障");

            dic[$"{176}.{0}"] = ("通讯故障", "P4-OP290L-AJ14-BK02通讯故障");
            dic[$"{176}.{1}"] = ("通讯故障", "P4-OP290R-AJ14-BK03通讯故障");
            dic[$"{176}.{2}"] = ("通讯故障", "P4-OP290R-AJ14-BK04通讯故障");
            dic[$"{176}.{3}"] = ("通讯故障", "P4-OP270R-AJ20-BK02通讯故障");
           

            dic[$"{181}.{0}"] = ("通讯故障", "P4-R23通讯故障");
            dic[$"{181}.{1}"] = ("通讯故障", "P4-R24通讯故障");
            dic[$"{181}.{2}"] = ("通讯故障", "P4-R25通讯故障");
            dic[$"{181}.{3}"] = ("通讯故障", "P4-R26通讯故障");
            dic[$"{181}.{4}"] = ("通讯故障", "P4-R27通讯故障");
            dic[$"{181}.{5}"] = ("通讯故障", "P4-R28通讯故障");
            dic[$"{181}.{6}"] = ("通讯故障", "P4-R29通讯故障");
            dic[$"{181}.{7}"] = ("通讯故障", "P4-R30通讯故障");
            dic[$"{182}.{0}"] = ("通讯故障", "P4-R31通讯故障");

            dic[$"{183}.{4}"] = ("通讯故障", "P4-OP210L有线扫码通讯故障");
            dic[$"{183}.{5}"] = ("通讯故障", "P4-OP210R有线扫码通讯故障");
            dic[$"{183}.{6}"] = ("通讯故障", "P4-OP250L无线扫描枪通讯故障");
            dic[$"{183}.{7}"] = ("通讯故障", "P4-OP250R无线扫描枪通讯故障");

            dic[$"{184}.{0}"] = ("通讯故障", "P4-OP280固定扫描枪1通讯故障");
            dic[$"{184}.{1}"] = ("通讯故障", "P4-OP280固定扫描枪2通讯故障");
            dic[$"{184}.{2}"] = ("通讯故障", "P4-返修区有线扫描枪通讯故障");

            dic[$"{186}.{0}"] = ("通讯故障", "P4-OP270L打刻机通讯故障");
            dic[$"{186}.{1}"] = ("通讯故障", "P4-OP270R打刻机通讯故障");

            dic[$"{188}.{4}"] = ("通讯故障", "P4-280相机—左上通讯故障");
            dic[$"{188}.{5}"] = ("通讯故障", "P4-280相机—左前通讯故障");
            dic[$"{188}.{6}"] = ("通讯故障", "P4-280相机—左下通讯故障");
            dic[$"{188}.{7}"] = ("通讯故障", "P4-280相机—左右通讯故障");

            dic[$"{189}.{0}"] = ("通讯故障", "P4-280相机—右后通讯故障");
            dic[$"{189}.{1}"] = ("通讯故障", "P4-280相机—左后通讯故障");
            dic[$"{189}.{2}"] = ("通讯故障", "P4-280相机—右上通讯故障");
            dic[$"{189}.{3}"] = ("通讯故障", "P4-280相机—右前通讯故障");
            dic[$"{189}.{4}"] = ("通讯故障", "P4-280相机—右左通讯故障");
            dic[$"{189}.{5}"] = ("通讯故障", "P4-280相机—右下通讯故障");

            dic[$"{191}.{0}"] = ("通讯故障", "P4-R23-FDS通讯故障");
            dic[$"{191}.{1}"] = ("通讯故障", "P4-R24-PM通讯故障");
            dic[$"{191}.{2}"] = ("通讯故障", "P4-R25-PM通讯故障");
            dic[$"{191}.{3}"] = ("通讯故障", "P4-R26-PM通讯故障");
            dic[$"{191}.{4}"] = ("通讯故障", "P4-R27-FDS通讯故障");
            dic[$"{191}.{5}"] = ("通讯故障", "P4-R28-PM通讯故障");
            dic[$"{191}.{6}"] = ("通讯故障", "P4-R29-PM通讯故障");
            dic[$"{191}.{7}"] = ("通讯故障", "P4-R30-PM通讯故障");

            dic[$"{192}.{0}"] = ("通讯故障", "P4-R31-PM通讯故障");
            dic[$"{192}.{1}"] = ("通讯故障", "P4-R24_BK01通讯故障");
            dic[$"{192}.{2}"] = ("通讯故障", "P4-R25_BK01通讯故障");
            dic[$"{192}.{3}"] = ("通讯故障", "P4-R26_BK01通讯故障");
            dic[$"{192}.{4}"] = ("通讯故障", "P4-R28_BK01通讯故障");
            dic[$"{192}.{5}"] = ("通讯故障", "P4-R29_BK01通讯故障");
            dic[$"{192}.{6}"] = ("通讯故障", "P4-R30_BK01通讯故障");
            dic[$"{192}.{7}"] = ("通讯故障", "P4-R31_BK01通讯故障");

            dic[$"{193}.{1}"] = ("通讯故障", "P4-R28_BK02通讯故障");
            dic[$"{193}.{2}"] = ("通讯故障", "P4-R29_BK02通讯故障");
            dic[$"{193}.{3}"] = ("通讯故障", "P4-R30_BK02通讯故障");
            dic[$"{193}.{4}"] = ("通讯故障", "P4-R31_BK02通讯故障");
            dic[$"{193}.{5}"] = ("通讯故障", "P4-R25侧涂胶机通讯故障");
            dic[$"{193}.{6}"] = ("通讯故障", "P4-R26侧涂胶机通讯故障");

            dic[$"{194}.{6}"] = ("通讯故障", "P4-OP220L马头枪通讯故障");
            dic[$"{194}.{7}"] = ("通讯故障", "P4-OP220R马头枪通讯故障");

            dic[$"{195}.{0}"] = ("通讯故障", "P4-OP250L马头枪通讯故障");
            dic[$"{195}.{1}"] = ("通讯故障", "P4-OP250R马头枪通讯故障");
            dic[$"{195}.{2}"] = ("通讯故障", "P4-OP260L-1马头枪通讯故障");
            dic[$"{195}.{3}"] = ("通讯故障", "P4-OP260L-2马头枪通讯故障");
            dic[$"{195}.{4}"] = ("通讯故障", "P4-OP260R-1马头枪通讯故障");
            dic[$"{195}.{5}"] = ("通讯故障", "P4-OP260R-2马头枪通讯故障");
            dic[$"{195}.{6}"] = ("通讯故障", "P4-返修区L马头枪通讯故障");
            dic[$"{195}.{7}"] = ("通讯故障", "P4-返修区R马头枪通讯故障");


            if (dic.TryGetValue($"{@byte}.{sty}", out var value))
            {
                return value;
            }

            return ("", "");
        }

        public static string GetDeviceNameFromIp(string ip)
        {
            Dictionary<string, string> dic = new Dictionary<string, string>();

            dic["192.168.10.103"] = "Op180L";
            dic["192.168.10.104"] = "Op190L";
            dic["192.168.10.105"] = "Op200L";
            dic["192.168.10.106"] = "Op220L";
            dic["192.168.10.107"] = "Op250L";
            dic["192.168.10.108"] = "Op260L_2";
            dic["192.168.10.109"] = "Op260L_1";

            dic["192.168.10.113"] = "Op180R";
            dic["192.168.10.114"] = "Op190R";
            dic["192.168.10.115"] = "Op200R";
            dic["192.168.10.116"] = "Op220R";
            dic["192.168.10.117"] = "Op250R";
            dic["192.168.10.118"] = "Op260R_2";
            dic["192.168.10.119"] = "Op260R_1";


            return dic[ip];
        }
    }
}